本文实例讲述了java执行Linux命令的方法。分享给大家供大家参考。具体实现方法如下:
        try
        {
            process = Runtime.getRuntime().exec(cmds);
            StreamGobbler errorGobbler = new StreamGobbler(process.getErrorStream(), \"Error\");
            StreamGobbler outputGobbler = new StreamGobbler(process.getInputStream(), \"Output\");
            errorGobbler.start();
            outputGobbler.start();
            try
            {
                process.waitFor();
            }
            catch (InterruptedException e)
            {
                e.printStackTrace();
            }
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }
}
本文地址:https://www.stayed.cn/item/25873
转载请注明出处。
本站部分内容来源于网络,如侵犯到您的权益,请 联系我
