X-Git-Url: http://gitweb.fperrin.net/?a=blobdiff_plain;f=src%2Ftim%2Fprune%2Ffunction%2Fsrtm%2FSrtmViewfinderSource.java;fp=src%2Ftim%2Fprune%2Ffunction%2Fsrtm%2FSrtmViewfinderSource.java;h=a25e9c4e95b55b68341a520df62ad19f54aac00e;hb=ee3eef52c05b36837d56bd4db582783da0ba0df4;hp=17790ae2f2b1cc3cee89bc4d7cad52fcb3104ac2;hpb=842bb718cc05d82d37cf6464175baa9f05c80297;p=GpsPrune.git 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) {