FileDocCategorySizeDatePackage
ReminderService.javaAPI DocExample1469Sun Feb 08 21:33:46 GMT 2004None

ReminderService

public class ReminderService extends Object
Read a file of reminders, run each when due using java.util.Timer
author
Ian F. Darwin, http://www.darwinsys.com/
version
$Id: ReminderService.java,v 1.7 2004/02/09 03:33:46 ian Exp $

Fields Summary
Timer
timer
The Timer object
Constructors Summary
Methods Summary
protected voidload()


		BufferedReader is = new BufferedReader(
			new FileReader("ReminderService.txt"));
		SimpleDateFormat formatter =
			new SimpleDateFormat ("yyyy MM dd hh mm");
		String aLine;
		while ((aLine = is.readLine()) != null) {
			ParsePosition pp = new ParsePosition(0);
			Date date = formatter.parse(aLine, pp);
			if (date == null) {
				message("Invalid date in " + aLine);
				continue;
			}
			String mesg = aLine.substring(pp.getIndex());
			timer.schedule(new Item(mesg), date);
		}
	
public static voidmain(java.lang.String[] argv)

		new ReminderService().load();
	
voidmessage(java.lang.String message)
Display a message on the console and in the GUI. Used both by Item tasks and by mainline parser.

		System.out.println("\007" + message);
		JOptionPane.showMessageDialog(null,
			message, 
			"Timer Alert",				// titlebar
			JOptionPane.INFORMATION_MESSAGE);	// icon