阅读背景:

使用Runtime运行linux命令_Lulixue的专栏

来源:互联网 
public boolean execute(String cmd) {
    String[] command = new String[] { "sh", "-c", cmd };
    Runtime runtime = Runtime.getRuntime();
    try {
        Process process = runtime.exec(command);
        BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream()));
        String line;
        StringBuffer pathBuf = new StringBuffer();

        while ((line = in.readLine()) != null) {
            pathBuf.append(line);
        }
        in.close();

    } catch (IOException e) {
        e.printStackTrace();
        return false;
    }
    return true;
}public boolean execute(String cmd) {
    String



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: