Java用Runtime.getRuntime().exec("echo hello!");
C用system("echo hello!");
C会把“hello!”输出到控制台,Java则没有输出。
1
1120101929 2015-03-30 13:12:27 +08:00
Runtime runtime = Runtime.getRuntime();
Process process = runtime.exec("cmd /c dir"); InputStream in = process.getInputStream(); Scanner scanner = new Scanner(in); while (scanner.hasNext()) { String line = scanner.nextLine(); System.out.println(line); } scanner.close(); in.close(); |
2
qw7692336 OP @1120101929 那C的呢
|