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 operation.
How to achieve all these as a web service?
Not that this has anything to do with webservices, but I suspect you need to use polling. That is, you submit a task to a ScheduledThreadPoolExecutor and the task regularly checks the contents of the director using File.listFiles() to determine if new files are present.
You can, if you wish, persist the state of the directory, but you need to decide on a policy in the case there is no previously persisted state, i.e. are present fiels new or old, as far as your "service" is concerned.