Win a copy of The Java Performance Companion this week in the Performance forum!
    Bookmark Topic Watch Topic
  • New Topic

how to check for the new file created in a directory

 
sudeep jha
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Report post to moderator
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.
 
Rob Spoor
Sheriff
Pie
Posts: 20546
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Report post to moderator
Please Use One Thread Per Question. Let's continue here.
 
    Bookmark Topic Watch Topic
  • New Topic