private String runConsoleCommand(String command) throws IOException ... { Process p = Runtime.getRuntime().exec(command); InputStream stdoutStream = new BufferedInputStream(p.getInputStream()); StringBuffer buffer = new StringBuffer(); while (true) ...{ int c = stdoutStream.read(); if (c == -1) ...{ break; } buffer.append((char) c); } String outputText = buffer.toString(); stdoutStream.close(); return outputText; }