I'm coding a Java Application right now and it has to read through a file. I'm using this method to do so:
BufferedReader mb_reader = new BufferedReader(new FileReader(f1));
int lines = 0;
while (null != (mb_line = mb_reader.readLine())) {
lines++;
//something to do
}
Everything works fine but it's possible that the file has to be changed from outside (for example).
I have a mthod that tests if the file exists and then open this reader. But if I now try to rename the file in the Windows Explorer
it just says that the file is opened in Java and can not be renamed.
Is there a way to make it possible to rename it even if it's opened?
You need to close the stream to release the file to the system, i don't think there's a straightforward way around this.
You could have a working copy to read from and check the file every now and then for changes you might expect.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments