|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object dk.netarkivet.common.utils.ProcessUtils
public class ProcessUtils
Various utilities for running processes -- not exactly Java's forte.
Constructor Summary | |
---|---|
ProcessUtils()
|
Method Summary | |
---|---|
static java.lang.Object |
collectProcessOutput(java.io.InputStream inputStream,
int maxCollect,
java.util.Set<java.lang.Thread> collectionThreads)
Collect all output from an inputstream, up to maxCollect bytes, in an output object. |
static void |
discardProcessOutput(java.io.InputStream inputStream)
Read the output from a process. |
static int |
runProcess(java.lang.String... programAndArgs)
Runs an external process that takes no input, discarding its output. |
static int |
runProcess(java.lang.String[] environment,
java.lang.String... programAndArgs)
Runs an external process that takes no input, discarding its output. |
static java.lang.Integer |
waitFor(java.lang.Process p,
long maxWait)
Wait for the end of a process, but only for a limited time. |
static void |
writeProcessOutput(java.io.InputStream inputStream,
java.io.File outputFile,
java.util.Set<java.lang.Thread> collectionThreads)
Collect all output from an inputstream, appending it to a file. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ProcessUtils()
Method Detail |
---|
public static int runProcess(java.lang.String[] environment, java.lang.String... programAndArgs)
environment
- An environment to run the process in (may be null)programAndArgs
- The program and its arguments.
public static int runProcess(java.lang.String... programAndArgs)
programAndArgs
- The program to run and its arguments
public static void discardProcessOutput(java.io.InputStream inputStream)
inputStream
- A stream to read up to end of file. This stream is closed at
some point in the future, but not necessarily before this
method returns.public static java.lang.Object collectProcessOutput(java.io.InputStream inputStream, int maxCollect, java.util.Set<java.lang.Thread> collectionThreads)
inputStream
- The inputstream to read contents frommaxCollect
- The maximum number of bytes to collect, or -1 for no
limitcollectionThreads
- Set of threads that concurrently collect output
public static void writeProcessOutput(java.io.InputStream inputStream, java.io.File outputFile, java.util.Set<java.lang.Thread> collectionThreads)
inputStream
- The inputstream to read contents fromoutputFile
- The file that output should be appended to.collectionThreads
- Set of threads that concurrently collect outputpublic static java.lang.Integer waitFor(java.lang.Process p, long maxWait)
p
- Process to wait formaxWait
- The maximum number of milliseconds to wait for the
process to exit.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |