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);
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)
{