X-Git-Url: http://gitweb.fperrin.net/?p=GpsPrune.git;a=blobdiff_plain;f=src%2Ftim%2Fprune%2Ffunction%2Fsrtm%2FSrtmGl1Source.java;h=f8639b7837a2bdf3ebae19b6837ddb71f759c87e;hp=51e6d770cee72fcef87eb19afdf1da633fc31234;hb=860ae36b24e22ff49b23cc5e3b51e9bd5520712b;hpb=8f45a9f2289e01d4f6eee6036f7fc3c4a92e3024 diff --git a/src/tim/prune/function/srtm/SrtmGl1Source.java b/src/tim/prune/function/srtm/SrtmGl1Source.java index 51e6d77..f8639b7 100644 --- a/src/tim/prune/function/srtm/SrtmGl1Source.java +++ b/src/tim/prune/function/srtm/SrtmGl1Source.java @@ -88,10 +88,7 @@ public class SrtmGl1Source extends SrtmSource { try { HttpURLConnection conn = (HttpURLConnection) tileUrl.openConnection(); - long fileLength = 0L; - // Define streams - FileOutputStream outStream = null; InputStream inStream = null; // Documentation about HTTP interface at: @@ -114,7 +111,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 +129,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 downloadToFile(inStream, outputFile); } catch (IOException e) {