Created
October 1, 2012 07:45
-
-
Save anonymous/3810155 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static String system(String cmds) { | |
| String value = ""; | |
| try { | |
| String cmd[] = { "/bin/sh", "-c", cmds}; | |
| Process p = Runtime.getRuntime().exec(cmd); | |
| p.waitFor(); | |
| BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream())); | |
| String line = reader.readLine(); | |
| while (line != null) { | |
| value += line + "\n\r"; | |
| line = reader.readLine(); | |
| } | |
| } | |
| catch (IOException ioe) { | |
| ioe.printStackTrace(); | |
| } | |
| catch (InterruptedException ie) { | |
| ie.printStackTrace(); | |
| } | |
| return value; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment