X-Git-Url: http://gitweb.fperrin.net/?p=GpsPrune.git;a=blobdiff_plain;f=src%2Ftim%2Fprune%2Ffunction%2Fsrtm%2FSrtmViewfinderSource.java;h=a25e9c4e95b55b68341a520df62ad19f54aac00e;hp=17790ae2f2b1cc3cee89bc4d7cad52fcb3104ac2;hb=860ae36b24e22ff49b23cc5e3b51e9bd5520712b;hpb=8f45a9f2289e01d4f6eee6036f7fc3c4a92e3024 diff --git a/src/tim/prune/function/srtm/SrtmViewfinderSource.java b/src/tim/prune/function/srtm/SrtmViewfinderSource.java index 17790ae..a25e9c4 100644 --- a/src/tim/prune/function/srtm/SrtmViewfinderSource.java +++ b/src/tim/prune/function/srtm/SrtmViewfinderSource.java @@ -130,15 +130,12 @@ public class SrtmViewfinderSource extends SrtmSource { throws SrtmSourceException { URL tileUrl = buildUrl(inTile); - File outputFile = getCacheFileName(inTile); System.out.println("Download: Need to download: " + tileUrl); - try { HttpURLConnection conn = (HttpURLConnection) tileUrl.openConnection(); // Define streams - FileOutputStream outStream = null; InputStream inStream = null; conn.setRequestProperty("User-Agent", "GpsPrune v" + GpsPrune.VERSION_NUMBER); @@ -157,17 +154,7 @@ public class SrtmViewfinderSource extends SrtmSource { throw new SrtmSourceException("Invalid response from server: " +status+conn.getContent()); } - outStream = new FileOutputStream(outputFile); - - int c; - while ((c = inStream.read()) != -1) - { - outStream.write(c); - } - // Make sure streams are closed - try {inStream.close();} catch (Exception e) {} - try {outStream.close();} catch (Exception e) {} - return true; + return downloadToFile(inStream, getCacheFileName(inTile)); } catch (IOException e) {