try
{
HttpURLConnection conn = (HttpURLConnection) tileUrl.openConnection();
- long fileLength = 0L;
-
// Define streams
- FileOutputStream outStream = null;
InputStream inStream = null;
// Documentation about HTTP interface at:
{
// Found the tile, we're good
inStream = conn.getInputStream();
- fileLength = conn.getContentLengthLong();
break;
}
else if (status == 302)
}
}
- // _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)
{