Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package rcreminder;
- import java.io.File;
- import java.io.FileReader;
- import java.io.BufferedReader;
- import javax.swing.JOptionPane;
- import java.util.Timer;
- import java.util.TimerTask;
- /**
- *
- * @author DenyingBelial
- */
- public class RCReminder {
- public static int TimerMS = 0;
- public static String Message = "";
- public static final Timer t = new Timer("Reminder");
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- // TODO code application logic here
- loadConfig();
- TimerTask showMessage = new TimerTask(){
- public void run(){
- JOptionPane.showMessageDialog(null, Message, "Reminder", 1);
- }
- };
- t.schedule(showMessage, 0, TimerMS);
- }
- public static void loadConfig(){
- try{
- File configF = new File("./conf.ini");
- if(!configF.exists()){configF.createNewFile();}
- FileReader configStream = new FileReader(configF);
- BufferedReader configBuf = new BufferedReader(configStream);
- String configString = configBuf.readLine();
- while(configString!=null){
- if(configString.contains("Timelapse=")){
- String timeVal = configString.substring("Timelapse=".length());
- TimerMS = Integer.parseInt(timeVal);
- }
- if(configString.contains("Message=")){
- String messVal = configString.substring("Message=".length());
- Message = messVal;
- }
- configString = configBuf.readLine();
- }
- }
- catch(Exception e){
- JOptionPane.showMessageDialog(null, "Error loading config file. "
- + "Please verify that the file exists and you have RW "
- + "permission. \n"+ e.toString(), "Error", 1);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement