If we open a file with my java application and open the same file with another application
and made some changes. The java application I made, should know it immedeately that this file
is changed by some external application, and prompt the user to load the fresh content.
How to do it using java?
Asked
Active
Viewed 67 times
0

Ranjan Sarma
- 1,565
- 5
- 22
- 36
-
Take a look at http://stackoverflow.com/questions/494869/file-changed-listener-in-java – The Cat Nov 15 '12 at 11:02
3 Answers
2
This question is asked before here
https://stackoverflow.com/questions/5379458/java-filewatcher
read this http://docs.oracle.com/javase/tutorial/essential/io/notification.html
1
You can make check in this handler:
frame.addWindowFocusListener(new WindowAdapter() {
public void windowGainedFocus(WindowEvent e) {
// TODO: read file again and compare with previous
}
});

CAMOBAP
- 5,523
- 8
- 58
- 93
0
I think you have to have thread that polls for file information. See this question File changed listener in Java.