X-Git-Url: http://gitweb.fperrin.net/?p=GpsPrune.git;a=blobdiff_plain;f=src%2Ftim%2Fprune%2Ffunction%2Fsrtm%2FSrtm3Source.java;h=cc0da79b1c790f85e4a21ca473ea06b8bd457c9d;hp=14fad598948ef796c702bcd633048b97d0d121be;hb=860ae36b24e22ff49b23cc5e3b51e9bd5520712b;hpb=8f45a9f2289e01d4f6eee6036f7fc3c4a92e3024 diff --git a/src/tim/prune/function/srtm/Srtm3Source.java b/src/tim/prune/function/srtm/Srtm3Source.java index 14fad59..cc0da79 100644 --- a/src/tim/prune/function/srtm/Srtm3Source.java +++ b/src/tim/prune/function/srtm/Srtm3Source.java @@ -110,7 +110,6 @@ public class Srtm3Source extends SrtmSource { public boolean downloadTile(SrtmTile inTile) throws SrtmSourceException { - int redirects = 5; URL tileUrl = buildUrl(inTile); File outputFile = getCacheFileName(inTile); System.out.println("Download: Need to download: " + tileUrl); @@ -120,7 +119,6 @@ public class Srtm3Source extends SrtmSource { HttpURLConnection conn = (HttpURLConnection) tileUrl.openConnection(); // Define streams - FileOutputStream outStream = null; InputStream inStream = null; conn.setRequestProperty("User-Agent", "GpsPrune v" + GpsPrune.VERSION_NUMBER); @@ -138,18 +136,7 @@ public class Srtm3Source 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, outputFile); } catch (IOException e) {