private static String streamToString(InputStream is) throws IOException {
    InputStreamReader isr = new InputStreamReader(is);
    BufferedReader reader = new BufferedReader(isr);
    StringBuilder sb = new StringBuilder();
    String line = null;
    while ((line = reader.readLine()) != null) {
      sb.append(line).append("\n");
    }
    return sb.toString();
  }
Run a command

@param args A String[] of the command and its arguments
@return Result
@throws IOException
@throws InterruptedException
ambari-server/src/main/java/org/apache/ambari/server/utils/ShellCommandUtil.java