This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Java in General and the fly likes how to check for the new file created in a directory Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Reply locked New topic
Author

how to check for the new file created in a directory

sudeep jha
Greenhorn

Joined: Sep 05, 2007
Posts: 19
I need a very simple process that listens on a directory.When a new file is created on that directory,
the new file has to be copied to a remote location.
I have created the listener but how can I check for new file from the set of files in directory using java code.
There is no creationdate method in java file api.There is only one lastmodifed() method for the java file metadata operations.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Assuming you use a Timer you can have a task the wakes up every n seconds and lists the contents of the directory. It could check this against some persistent list of file names stored when it last ran and copy any files not previously listed.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19541
    
  16

Please Use One Thread Per Question. Let's continue here.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to check for the new file created in a directory
 
Similar Threads
passing file directory to function
File I/O
IO
how to check for the new file created in a directory
how to check for the new file created in a directory