62,634
社区成员




package cn.bj.reboot;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
public class reboot {
static String filename = "D:\\reboot.bat";
public static void main(String[] args) {
create();
going();
}
public static void create(){
File file = new File(filename);
RandomAccessFile raf = null;
try {
raf = new RandomAccessFile(filename,"rw");
String closed = "shutdown -s -t 30";
raf.writeBytes(closed);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static void going(){
Runtime rt = Runtime.getRuntime();
try {
rt.exec(filename);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}