This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
    Bookmark Topic Watch Topic
  • New Topic

how to check for the new file created in a directory  RSS feed

 
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
Posts: 21090
85
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
Boost this thread!