Hello Everyone I have a file/folder which needs to be monitored for period of time. How can i check to see if the new files have been added or deleted or changed in the directory? can i use XML with java to take a snap shot of the file and compare when it changes? if so how do you do it? thanks sathish
posted 16 years ago
You can use some of java.io.File's methods to check. This can be used on directories to find out how many files they contain etc., and with files they tell you the file's 'last modified' attribute. If you need to get into more detail, you can calculate a checksum for a file, store this (normally it's a long), and, when you need to check if the file's changed, calculate it's checksum again and compare them. If you want to find out about checksums, look at java.uitl.zip.CRC32 or ADlER32. Hope that helps. Grant.
I am going to test your electrical conductivity with this tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads