|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectProcessRunner
public class ProcessRunner
Copyright (c) 2009, Regents of the University of California All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - Neither the name of the University of California nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Nested Class Summary | |
---|---|
static class |
ProcessRunner.CommandFailedException
Exception thrown if an external command ends with a non-zero exit status. |
private static class |
ProcessRunner.InputStuffer
Class to stuff input into the process's input stream (an OutputStream to us). |
private static class |
ProcessRunner.Interrupter
Used to interrupt the main thread if a timeout occurs |
private static class |
ProcessRunner.OutputGrabber
Class to accumulate the output from a process's output stream (which is an InputStream to us), and turn it into a string. |
Constructor Summary | |
---|---|
ProcessRunner()
|
Method Summary | |
---|---|
static byte[] |
runAndGrab(String[] argArray,
byte[] inputBytes,
int timeout)
Run the external process, applying a timeout if specified, feeding it input on stdin and gathering the results from stdout. |
static String |
runAndGrab(String[] argArray,
String input,
int timeout)
Run the external process, applying a timeout if specified, feeding it input on stdin and gathering the results from stdout. |
Methods inherited from class Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ProcessRunner()
Method Detail |
---|
public static String runAndGrab(String[] argArray, String input, int timeout) throws InterruptedException, ProcessRunner.CommandFailedException, IOException
IOException
- If something goes wrong starting the process.
InterruptedException
- If process exceeds the given timeout.
ProcessRunner.CommandFailedException
- If the process exits with non-zero status.public static byte[] runAndGrab(String[] argArray, byte[] inputBytes, int timeout) throws InterruptedException, ProcessRunner.CommandFailedException, IOException
IOException
- If something goes wrong starting the process.
InterruptedException
- If process exceeds the given timeout.
ProcessRunner.CommandFailedException
- If the process exits with non-zero status.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |