Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to detect a file saved?

Status
Not open for further replies.

thirsty

Programmer
Nov 21, 2002
2
US
Hi, I am writing a multi-client java text editor. I wish to implement the text editor in such a way that when one file is opened by 2 users or more and one of them edit and saved the file, there will be a popup message telling other users that the file has been modified and ask them if they want to load the new file or not.

How do I implement this? Use ActionListener?
 
This is tough. If you are allowing multithreaded or multi-process access, you will have to use some kind of synchronization primitive (e.g. a lock file) to check for multiple access. To handle refreshes if another user saves the file, you will probably want to have a refresh thread that periodically polls the last modified date of the file and alerts you if the last modified date is different from when you opened the file.

In general, you can't use listeners to communicate among users unless you are limiting your application to running in a single process space (i.e. the same JVM). This would be a serious constraint on a multi-user text editor where users are apt to be geographically distant unless you used a client server approach where the server handled client interaction.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top