大神们 小弟谢了一个定时关机的功能功能帮忙看一下是否正确
package Interface;import java.io.IOException;
import java.util.Calendar;
import java.util.Timer;
import java.util.TimerTask;public class ShoutdownSystem extends TimerTask {
Timer timer = new Timer();
static ShoutdownSystem shoutdown = new ShoutdownSystem();
private String shoutdownH = "5";
private String shoutdownM = "30";
public void run(){
int thisH = Calendar.HOUR_OF_DAY;
int thisM = Calendar.MINUTE;
String dayH = String.valueOf(thisH);
String dayM = String.valueOf(thisM);
if(shoutdownH.equals(dayH) && shoutdownM.equals(dayM)){
try {
Runtime.getRuntime().exec("shutdown -s");
} catch (IOException e) {
e.printStackTrace();
}finally{
timer.schedule(shoutdown, 10000, 50000);
}
}
}
}