X-Git-Url: https://gitweb.fperrin.net/?a=blobdiff_plain;f=src%2Ftim%2Fprune%2Ffunction%2Fsrtm%2FSrtmGl1Source.java;fp=src%2Ftim%2Fprune%2Ffunction%2Fsrtm%2FSrtmGl1Source.java;h=0a74043402e4999a4e4fc37d9ff77b9b0c5ac609;hb=b436c60b4dff131a6c2794851068bc6a61f6062a;hp=51e6d770cee72fcef87eb19afdf1da633fc31234;hpb=7a0d2c388f91bfdea7974d7fb1ba3424fb21bf7b;p=GpsPrune.git diff --git a/src/tim/prune/function/srtm/SrtmGl1Source.java b/src/tim/prune/function/srtm/SrtmGl1Source.java index 51e6d77..0a74043 100644 --- a/src/tim/prune/function/srtm/SrtmGl1Source.java +++ b/src/tim/prune/function/srtm/SrtmGl1Source.java @@ -84,14 +84,10 @@ public class SrtmGl1Source extends SrtmSource { { URL tileUrl = buildUrl(inTile); File outputFile = getCacheFileName(inTile); - System.out.println("Download: Need to download: " + tileUrl); try { HttpURLConnection conn = (HttpURLConnection) tileUrl.openConnection(); - long fileLength = 0L; - // Define streams - FileOutputStream outStream = null; InputStream inStream = null; // Documentation about HTTP interface at: @@ -114,7 +110,6 @@ public class SrtmGl1Source extends SrtmSource { { // Found the tile, we're good inStream = conn.getInputStream(); - fileLength = conn.getContentLengthLong(); break; } else if (status == 302) @@ -133,22 +128,7 @@ public class SrtmGl1Source extends SrtmSource { } } - // _progress.setValue(t * 10 + 1); - outStream = new FileOutputStream(outputFile); - - // Copy all the bytes to the file - int c; - long written = 0L; - while ((c = inStream.read()) != -1) - { - outStream.write(c); - written++; - // _progress.setValue(t * 10 + 1 + (int) ((10 * written) / fileLength)); - } - // Make sure streams are closed - try {inStream.close();} catch (Exception e) {} - try {outStream.close();} catch (Exception e) {} - return true; + return readToFile(inStream, outputFile); } catch (IOException e) {