Package net.sf.basedb.util
Class FileCopyRunnable
- java.lang.Object
-
- net.sf.basedb.util.FileCopyRunnable
-
- All Implemented Interfaces:
Runnable
public class FileCopyRunnable extends Object implements Runnable
Runnable implementation that copies data from an input stream to an output stream when executed. This is useful when executing external processes since reading and writing to their stdin and stdout is best done with separate thread.- Since:
- 2.15
- Author:
- nicklas
- Last modified
- $Date $
-
-
Field Summary
Fields Modifier and Type Field Description private Throwable
error
private InputStream
in
private OutputStream
out
-
Constructor Summary
Constructors Constructor Description FileCopyRunnable(InputStream in, OutputStream out)
Create a new file copy object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Throwable
getError()
Get the exception that was thrown when executing the file copy operation.boolean
hasError()
A boolean flag indicating if the copying was sucessful or not.void
run()
-
-
-
Field Detail
-
in
private final InputStream in
-
out
private final OutputStream out
-
error
private Throwable error
-
-
Constructor Detail
-
FileCopyRunnable
public FileCopyRunnable(InputStream in, OutputStream out)
Create a new file copy object. The stream are automatically closed in case of an error- Parameters:
in
- The input stream to read data from (required)out
- The output stream to write data to (optional; if not given the input stream is read and then discarded)
-
-
Method Detail
-
hasError
public boolean hasError()
A boolean flag indicating if the copying was sucessful or not. This method should only be called after the thread has ended.- See Also:
getError()
-
getError
public Throwable getError()
Get the exception that was thrown when executing the file copy operation. This method should only be called after the thread has ended.- Returns:
- An error or null if the operation was sucessful
- See Also:
hasError()
-
-