I've create this function...
void DownloadFromDatabase() throws IOException {
URL website = new URL("http://theurlofmywebsite.org/databases/record_file.txt");
ReadableByteChannel rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream("record_file.txt");
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
}
... and I call it when I click a button as you can see here.
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
try {
DownloadFromDatabase();
} catch (IOException ex) {
Logger.getLogger(xGrep.class.getName()).log(Level.SEVERE, null, ex);
}
}
When I click the button, DownloadFromDatabase();
is called but I don't see the file record_file.txt
on my desktop. Do you know why?