1 |
filippis |
13 |
package tools; |
2 |
|
|
|
3 |
|
|
import java.io.*; |
4 |
|
|
|
5 |
|
|
public class SystemCmd { |
6 |
|
|
|
7 |
|
|
public static String exec(String[] cmd) { |
8 |
|
|
|
9 |
|
|
String output = ""; |
10 |
|
|
|
11 |
|
|
try { |
12 |
|
|
|
13 |
|
|
String line = ""; |
14 |
|
|
Process p = Runtime.getRuntime().exec(cmd); |
15 |
|
|
BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream())); |
16 |
|
|
while ((line = input.readLine()) != null) { |
17 |
|
|
output = output + line + "\n"; |
18 |
|
|
} |
19 |
|
|
input.close(); |
20 |
|
|
|
21 |
|
|
} catch (Exception err) { |
22 |
|
|
err.printStackTrace(); |
23 |
|
|
} |
24 |
|
|
|
25 |
|
|
return output; |
26 |
|
|
|
27 |
|
|
} |
28 |
duarte |
31 |
|
29 |
|
|
public static String exec(String cmd) { |
30 |
|
|
String[] cmdarr={cmd}; |
31 |
|
|
String output=exec(cmdarr); |
32 |
|
|
return output; |
33 |
|
|
} |
34 |
filippis |
13 |
|
35 |
duarte |
31 |
|
36 |
filippis |
13 |
} |
37 |
|
|
|