I have a simple Swing application that is contained in a JFrame. To quit/exit the application, I simply used the:
myJFrame.setDefaultCloseOperation(EXIT_ON_CLOSE)
so it quits when you click the X in the corner, but I want to call to delete a lock file when I quit the application. How can I do this?
Or is there an easier way to setup File Locking with Java 1.4.2? I know there is something using FileChannel and FileLock but it seems complicated.
I just want my program to not open a file if another person has the file already open. So I thought I would just create a dummy lock file when I open it, and test for it when you try and open. But it needs to be deleted when I quit.
Question
spacey
I have a simple Swing application that is contained in a JFrame. To quit/exit the application, I simply used the:
myJFrame.setDefaultCloseOperation(EXIT_ON_CLOSE)
so it quits when you click the X in the corner, but I want to call to delete a lock file when I quit the application. How can I do this?
Or is there an easier way to setup File Locking with Java 1.4.2? I know there is something using FileChannel and FileLock but it seems complicated.
I just want my program to not open a file if another person has the file already open. So I thought I would just create a dummy lock file when I open it, and test for it when you try and open. But it needs to be deleted when I quit.
Any help would be greatly appreciated.
Link to comment
Share on other sites
1 answer to this question
Recommended Posts