On Ubuntu linux, when you watch a flash video, it gets saved temporarily in the /tmp as flv files while the video buffers. I use vlc to directly play these files.
Currently, I have scripted a shortcut that directly scans and opens the latest file in /tmp with vlc, when clicked.
But, I want to program a Java application that will continually monitor this /tmp directory for any new flv files, and open it in vlc automatically. I know I can use Runtime.exec() to open the VLC application with the flv files. But, I DO NOT want to run a while(true) loop (with sleep) to scan for files.
How can I make use of Event Handling (Java or any other language) on Linux to complete this task?
Edit:
I am also wondering if Java is the right way to approach this. As someone suggested below, Python and QT seem more appropriate.