I am trying to check if a certain java.io.File is open by an external program. On windows I use this simple trick:
try {
FileOutputStream fos = new FileO
Thanks for the original suggestion. I have one small upgrade that is somewhat important to that method:
FileOutputStream fos = null;
try {
// Make sure that the output stream is in Append mode. Otherwise you will
// truncate your file, which probably isn't what you want to do :-)
fos = new FileOutputStream(file, true);
// -> file was closed
} catch(IOException e) {
// -> file still open
} finally {
if(fos != null) {
try {
fos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
Cheers, Gumbatron