List of usage examples for org.apache.commons.io FileUtils forceDeleteOnExit
public static void forceDeleteOnExit(File file) throws IOException
From source file:solarrecorder.SolarRecorder.java
public static void main(String[] args) { File lockFile = new File(System.getProperty("user.home") + File.separator + ".solarRecorder"); int attempts = 5; while (lockFile.exists() && attempts-- >= 0) { try {//from w w w . ja v a2 s . c o m Thread.sleep(2000); } catch (Exception ex) { ex.printStackTrace(); } } if (attempts < 0) { System.exit(-1); } try { lockFile.createNewFile(); FileUtils.forceDeleteOnExit(lockFile); long interval = 15; if (args.length > 1) { interval = Long.parseLong(args[1]); } String tempDir = "/tmp"; if (System.getProperty("os.name").contains("Windows")) { tempDir = "C:\\temp"; } new SolarRecorder(interval); } catch (IOException ex) { ex.printStackTrace(); } }