Simple File Watcher

S

smartnhandsome

Can some one suggest a way to monitor a directory to see a know file
named file is put in a directory using Java.

Thanks In advance.

Regards
 
G

Gordon Beaton

Can some one suggest a way to monitor a directory to see a know file
named file is put in a directory using Java.

Even though your OS's may provide a callback mechanism for monitoring
the file system, in Java you need to poll:

File f = new File("/some/directory/myfile.foo");
while (!f.exists()) Thread.sleep(10);

/gordon

--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top