]> gitweb.fperrin.net Git - GpsPrune.git/blobdiff - src/tim/prune/function/srtm/Srtm3Source.java
Download tiles in chunks
[GpsPrune.git] / src / tim / prune / function / srtm / Srtm3Source.java
index 14fad598948ef796c702bcd633048b97d0d121be..cc0da79b1c790f85e4a21ca473ea06b8bd457c9d 100644 (file)
@@ -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)
                {