📄 osexecute.java
字号:
package myutils;
import java.io.*;
public class OSExecute {
public static void command(String command){
boolean err = false;
try{
Process process = new ProcessBuilder(command.split("")).start();
BufferedReader results = new BufferedReader(
new InputStreamReader(process.getInputStream()));
String s;
while((s = results.readLine())!= null)
System.out.println(s);
BufferedReader errors = new BufferedReader(
new InputStreamReader(process.getErrorStream()));
//report errors and return nonzero valus to calling process if there are problems
while((s = errors.readLine())!= null){
System.err.println(s);
err = true;
}
}catch(Exception e){
//compensste for windows 2000, which throw an exception for the default command line:
if(command.startsWith("CMD/C"))
command("CMD/C"+command);
else
throw new RuntimeException(e);
}
if(err)
//throw new OSExecuteException("Errors executing" + command);
System.out.println("Errors2 executing" + command);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -