Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package com.ctt.sshlistener; import com.ctt.sshlistener.infrastructure.FilesMonitor; import java.io.File; import java.io.FileReader; import java.io.IOException; import java.util.Properties; import java.util.logging.Level; import java.util.logging.Logger; import org.apache.commons.io.FileUtils; import org.apache.commons.io.monitor.FileAlterationMonitor; import org.apache.commons.io.monitor.FileAlterationObserver; /** * * @author aleji_000 */ public class Main { public static Properties prop; public static void main(String[] args) throws Exception { Main.prop = new Properties(); FileReader reader = new FileReader("../config.properties"); Main.prop.load(reader); String directory = Main.prop.getProperty("directory"); FilesMonitor listener = new FilesMonitor(); File folder = new File(directory); try { FileAlterationObserver observer = new FileAlterationObserver(directory); FileAlterationMonitor monitor = new FileAlterationMonitor(10000); observer.addListener(listener); monitor.addObserver(observer); monitor.start(); } catch (Exception io) { } } public static void appendLog(String log) { try { FileUtils.write(new File(Main.prop.getProperty("log") + "log.log"), "\n" + log, true); } catch (IOException ex) { System.out.println(ex.getMessage()); } } }