Switch to full style
Java2 codes,problems ,discussions and solutions are here
Post a reply

Java File age monitoring

Tue Oct 21, 2008 7:59 pm

Currently i'm developing an appilcation(notifier) for monitoring amount of files
in hot folder (transaction folder) which is another engine move several file
from that folder. If the amount of files get bigger and bigger in the hot folder
then that is a signal indication that an engine was hang or down, so my
application will notify to anybody via Email.

Question is:

What is suitable java methode or how to monitoring the age of file in the hot
folder,whereas the amount of file in hot folder is fluctuatif ?



Re: Java File age monitoring

Tue Oct 21, 2008 8:00 pm

To find the number of files in a directory:
1) Get a File object for the directory:
File dir = new File ("dir/path");
2) Get the number of files in that direcory:
String [] names = dir.list ();
3) Get the size of the name list. This is the number of files in the
directory.
int numEntries = names.length;

To do this periodically, put this in the run () method of a TimerTask,
and set up the TimerTask to execute periodically through a Timer object.
To get the Javadoc for these classes, see
http://java.sun.com/j2se/1.5.0/docs/api/ .

Post a reply
  Related Posts  to : Java File age monitoring
 Copy file to file in java code- implementation     -  
 Encrypt/Decrypt a file from source file to target file.     -  
 get the Contents of a ZIP File in java     -  
 Creating a JAR file in Java     -  
 Create set up file of my java application     -  
 Write and Read to File In Java Example     -  
 Marshal Java object to XML file     -  
 passing string value from java to .exe file     -  
 How to create a file in java script using FireFox     -  
 insert information in html file with java     -