OCAJP 7, OCPJP 7
Scott Shipp wrote:Hi Nick,
What were you using to create, delete, and modify those particular files? This may be more about the particular software in question than anything else. For instance, if you open a Microsoft Word document and start typing, before you actually save anything the stuff you are typing gets saved to a temporary file. This provides the document recovery feature that word has, where if you experience some kind of system crash, power outage, etc. when you open Word again, the stuff is still there in the document recovery window (I cannot remember off the top of my head for sure if it is called document recovery but it is something like that). So when you say "I did not create or delete anything...." maybe you didn't, directly, but your editor or whatever did.
OCAJP 7, OCPJP 7
Richard Tookey wrote:You seem to be using 'gedit' to edit the text file /home/widelec/Desktop/Widelec.txt and then saving it using either ^S or the menu item File->Save . As I would expect, 'gedit' creates a temporary file containing your updated file content (in your case goutputstream-N2FJ1W) as part of the save to make sure the new file is written before deleting the old file. The file Widelec.txt file is renamed to Widelec.txt~ and then the temporary file is renamed to Widelec.txt . Your output seems consistent with this.
Since you are using Linux (or some other *Nix) renaming a file using 'mv' (to the same volume) does not change the file in any way, it just changes the directory entry. I suppose this makes the 'delete' followed by 'create' a little misleading but is acceptable to me since it does not actually change a files content; it only changes a directory entry. I bet you would get a very different output for 'mv' if you moved to a different volume.
Nick Widelec wrote:
Hi Richard,
So the file never gets deleted, it's just a trigger which triggers each time the file watched disappear right? Consider that it happens also when I move a file out of a folder. It triggers delete, so it would be safe saying that both DELETE and CREATE are just triggers related to when a file appear or disappear within the file system bit being watched with WatchService.
Am I right?
.
Richard Tookey wrote:
Nick Widelec wrote:
Hi Richard,
So the file never gets deleted, it's just a trigger which triggers each time the file watched disappear right? Consider that it happens also when I move a file out of a folder. It triggers delete, so it would be safe saying that both DELETE and CREATE are just triggers related to when a file appear or disappear within the file system bit being watched with WatchService.
Am I right?
.
The '~' file content and directory entry get deleted before a new '~' file is created. Moving a file out of a folder is not the same as moving it a different volume as only the directory entry changes. As to the detail of what the DELETE and CREATE events are you would need to find someone more knowledgeable than me if you want a definitive description. It could be that the DELETE and CREATE events are generated so that they are similar to what one gets in Windows.
Nick Widelec wrote:Whereas for MODIFY it should check for the present of those gooutputstream..
OCAJP 7, OCPJP 7
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |