?? scheduler.java
字號:
package com.javapatterns.chainofresp.scheduler;
import java.util.*;
import java.io.IOException;
public class Scheduler
{
private static Timer timer = new Timer();
public static void main(String []args)
{
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY, 10);
calendar.set(Calendar.MINUTE, 30);
calendar.set(Calendar.SECOND, 30);
Date time = calendar.getTime();
timer.schedule(new ScheduledTask(), time);
System.out.println("A job has been scheduled at " + time);
}
static class ScheduledTask extends TimerTask
{
public void run()
{
try
{
String command = "notepad c:/boot.ini";
Process child = Runtime.getRuntime().exec(command);
System.out.println("The scheduled job has been executed.");
}
catch (IOException e)
{
System.out.println("Exception " + e);
}
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -