Package cern.accsoft.steering.jmad.util
Class FileMonitor
- java.lang.Object
-
- cern.accsoft.steering.jmad.util.FileMonitor
-
public class FileMonitor extends java.lang.Object
polls a file and terminates as soon as it exists.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
FileMonitor.ProcessTerminatedUnexpectedlyException
static class
FileMonitor.WaitingFailedException
Will be thrown, if the waiting fails for some reason.
-
Constructor Summary
Constructors Constructor Description FileMonitor(java.io.File file)
FileMonitor(java.io.File file, java.lang.Process process)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
waitForFile()
waits forever, until the file exists.boolean
waitForFile(java.lang.Long timeout)
waits until a file exists.
-
-
-
Method Detail
-
waitForFile
public boolean waitForFile() throws JMadException
waits forever, until the file exists.- Returns:
- true, if it exists finally, false, if the monitored process was interrupted
- Throws:
FileMonitor.WaitingFailedException
- if something goes wrong during waitingJMadException
-
waitForFile
public boolean waitForFile(java.lang.Long timeout) throws JMadException
waits until a file exists.- Parameters:
timeout
- the maximum millisecs to wait (if null, then we wait forever ...)- Returns:
- true, if the file finally exists, false, if the monitored process was interrupted or we timed out.
- Throws:
FileMonitor.WaitingFailedException
- if something goes wrong during the waitingJMadException
-
-