Class ExecUtil

java.lang.Object
de.tomatengames.util.ExecUtil

public class ExecUtil extends Object
Provides methods to run subprocesses.
Since:
1.0
  • Method Details

    • execGet

      public static ExecGetResult execGet(String[] cmd, String[] envp, File dir, byte[] input) throws IOException
      Starts a process using Runtime.exec(String[], String[], File), and waits for the process to terminate. Meanwhile, the standard output and the error output of the process are read into memory.
      Parameters:
      cmd - The command to call and its arguments. Must not be null.
      envp - Environment variables in the format specified by Runtime.exec(String[], String[], File). May be null.
      dir - The working directory of the subprocess. May be null.
      input - Bytes to write to the standard input of the subprocess. May be null.
      Returns:
      An result object containing the standard output of the subprocess, the exit value, ...
      Throws:
      IOException - If an error occurs.
    • execGet

      public static ExecGetResult execGet(String... cmd) throws IOException
      Starts a process using Runtime.exec(String[]), and waits for the process to terminate. Meanwhile, the standard output and the error output of the process are read into memory.
      Parameters:
      cmd - The command to call and its arguments. Must not be null.
      Returns:
      An result object containing the standard output of the process, the exit value, ...
      Throws:
      IOException - If an error occurs.
    • execGetOutput

      public static String execGetOutput(String[] cmd, String[] envp, File dir) throws IOException
      Starts a process using Runtime.exec(String[], String[], File), and waits for the process to terminate. Meanwhile, the standard output and the error output of the process are read into memory. The exit value of the process must be 0.
      Parameters:
      cmd - The command to call and its arguments. Must not be null.
      envp - Environment variables in the format specified by Runtime.exec(String[], String[], File). May be null.
      dir - The working directory of the subprocess. May be null.
      Returns:
      The standard output as String.
      Throws:
      IOException - If an error occurs or the exit value of the process is not 0.
      See Also:
    • execGetOutput

      public static String execGetOutput(String... cmd) throws IOException
      Starts a process using Runtime.exec(String[]), and waits for the process to terminate. Meanwhile, the standard output and the error output of the process are read into memory. The exit value of the process must be 0.
      Parameters:
      cmd - The command to call and its arguments. Must not be null.
      Returns:
      The standard output as String.
      Throws:
      IOException - If an error occurs or the exit value of the process is not 0.
      See Also: