suffix = ".tmp"; // other image formats...
}
File file = File.createTempFile("jsky", suffix, new File(dir));
ProgressPanel progressPanel = getProgressPanel();
ProgressBarFilterInputStream in = progressPanel.getLoggedInputStream(url);
FileOutputStream out = new FileOutputStream(file);
// copy the data
byte[] buffer = new byte[8 * 1024];
while (true) {
int bytesRead = in.read(buffer);
if (bytesRead == -1) {
break;
}
if (progressPanel.isInterrupted()) {
throw new ProgressException("Interrupted");
}
out.write(buffer, 0, bytesRead);
}
in.close();
out.flush();
out.close();
if (!progressPanel.isInterrupted()) {
SwingUtilities.invokeLater(new NavigatorImageLoader(file.toString(), url));