public String run(@Nullable byte[] stdin) throws IOException, InterruptedException {
    ProcessBuilder processBuilder = new ProcessBuilder(command);
    if (workingDir != null) {
      processBuilder.directory(workingDir.toFile());
    }
    Process process = processBuilder.start();

    if (stdin != null) {
      // Write out stdin.
      try (OutputStream outputStream = process.getOutputStream()) {
        outputStream.write(stdin);
      }
    }

    // Read in stdout.
    try (InputStreamReader inputStreamReader =
        new InputStreamReader(process.getInputStream(), StandardCharsets.UTF_8)) {
      String output = CharStreams.toString(inputStreamReader);

      if (process.waitFor() != 0) {
        String stderr =
            CharStreams.toString(
                new InputStreamReader(process.getErrorStream(), StandardCharsets.UTF_8));
        throw new RuntimeException("Command '" + String.join(" ", command) + "' failed: " + stderr);
      }

      return output;
    }
  }
Runs the command and pipes in {@code stdin}.
jib-core/src/integration-test/java/com/google/cloud/tools/jib/Command.java