I am downloading a file from the net and then reading it using a BufferedReader. Currently I download the file using DownloadManager then have this code :
while (latestNumbersFile.exists() != true) {
System.out.println("WAITING...");
}
try {
Thread.sleep(5000);
} catch (InterruptedException ignored) {
}
So that any following code does not execute until the file has finished downloading. This works but seams really dirty to me.
If I remove the Thread.sleep(5000);
it seams that the file does indeed exist but is not quite ready to be read.
There has to be a better way of recognizing when a file not only exists but is actually complete and ready to have something preformed on it.
Any thoughts?? (sorry if this is a noobie question, I've searched high and low for an answer)