您的位置:首页 > 运维架构 > Linux

Java 调用Linux 系统关机命令

2008-08-24 12:58 465 查看
在Fedora 上测试通过

import java.io.*;
public class RunPing {

public static void main(String[] argv) {
try {
Runtime runtime=Runtime.getRuntime();
Process process=runtime.exec("halt -p");
BufferedReader reader=new BufferedReader(new InputStreamReader(process.getInputStream()));
String line;
while((line=reader.readLine())!=null) {
System.out.println(line);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: