This week's book giveaway is in the HTML/CSS/JavaScript forum.
We're giving away four copies of Practical SVG and have Chris Coyier on-line!
See this thread for details.
Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to check for the changed file

 
sathish
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Grant Crofton
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!