0

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?

Ranjan Sarma
  • 1,555
  • 5
  • 22
  • 36

3 Answers3

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

Community
  • 1
  • 1
Sap
  • 5,070
  • 7
  • 55
  • 97
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,228
  • 8
  • 56
  • 87
0

I think you have to have thread that polls for file information. See this question File changed listener in Java.

Community
  • 1
  • 1
The Cat
  • 2,463
  • 6
  • 23
  • 35