Package org.apache.tika.utils
Class ProcessUtils
java.lang.Object
org.apache.tika.utils.ProcessUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleancheckCommand(String[] checkCmd, int... errorValue) Checks to see if the command can be run.static booleancheckCommand(String checkCmd, int... errorValue) Checks to see if the command can be run.static StringescapeCommandLine(String arg) This should correctly put double-quotes around an argument if ProcessBuilder doesn't seem to work (as it doesn't on paths with spaces on Windows)static FileProcessResultexecute(ProcessBuilder pb, long timeoutMillis, int maxStdoutBuffer, int maxStdErrBuffer) This writes stdout and stderr to the FileProcessResult.static FileProcessResultexecute(ProcessBuilder pb, long timeoutMillis, Path stdoutRedirect, int maxStdErrBuffer) This redirects stdout to stdoutRedirect path.static String
-
Constructor Details
-
ProcessUtils
public ProcessUtils()
-
-
Method Details
-
escapeCommandLine
This should correctly put double-quotes around an argument if ProcessBuilder doesn't seem to work (as it doesn't on paths with spaces on Windows)- Parameters:
arg-- Returns:
-
unescapeCommandLine
-
execute
public static FileProcessResult execute(ProcessBuilder pb, long timeoutMillis, int maxStdoutBuffer, int maxStdErrBuffer) throws IOException This writes stdout and stderr to the FileProcessResult.- Parameters:
pb-timeoutMillis-maxStdoutBuffer-maxStdErrBuffer-- Returns:
- Throws:
IOException
-
execute
public static FileProcessResult execute(ProcessBuilder pb, long timeoutMillis, Path stdoutRedirect, int maxStdErrBuffer) throws IOException This redirects stdout to stdoutRedirect path.- Parameters:
pb-timeoutMillis-stdoutRedirect-maxStdErrBuffer-- Returns:
- Throws:
IOException
-
checkCommand
Checks to see if the command can be run. Typically used with something like "myapp --version" to check to see if "myapp" is installed and on the path.- Parameters:
checkCmd- The check command to runerrorValue- What is considered an error value? Default is 127 (command not found).- Returns:
- true if the command ran successfully (exit code not in errorValue list)
-
checkCommand
Checks to see if the command can be run. Typically used with something likenew String[]{"myapp", "--version"}to check to see if "myapp" is installed and on the path.- Parameters:
checkCmd- The check command to runerrorValue- What is considered an error value? Default is 127 (command not found).- Returns:
- true if the command ran successfully (exit code not in errorValue list)
-