想用java做个东西实现定时提醒
比如在每周5的下午6点提醒我 “今天回去给老婆洗衣服”
我的想法是定时提醒程序应该是要一直运行的吧?
但是我的电脑肯定随时都可能关闭
我想能否在我启动电脑的时候就自动启动运行那个定时提醒程序思路这样可以么?最大的问题在于程序随计算机启动而运行呢
比如在每周5的下午6点提醒我 “今天回去给老婆洗衣服”
我的想法是定时提醒程序应该是要一直运行的吧?
但是我的电脑肯定随时都可能关闭
我想能否在我启动电脑的时候就自动启动运行那个定时提醒程序思路这样可以么?最大的问题在于程序随计算机启动而运行呢
你的在开始进程中添加自己的进程import java.util.*;
import java.io.*;public class TimerUse
{
public static void main(String[] args)
{
PickTask pt = new PickTask();
pt.start(1,3);
}
}class PickTask
{
private Timer timer; public PickTask()
{
timer = new Timer();
}
private TimerTask task = new TimerTask()
{
public void run()
{
try
{
BufferedReader br = new BufferedReader(new FileReader("ming.txt"));
String data = null;
while((data=br.readLine())!=null)
{
System.out.println(data);
}
}
catch(FileNotFoundException e)
{
System.out.println("can not find the file");
}
catch(IOException e)
{
e.printStackTrace();
}
}
};
public void start(int delay,int internal )
{
timer.schedule(task,delay*1000,internal*1000);
}
}
C:\Documents and Settings\Administrator\「开始」菜单\程序\启动这样就可以开机的时候就自启动了。
按照3楼的做法,还需要写个Windows脚本或者批处理程序,
内容就是将java程序启动。