List of usage examples for org.apache.commons.io.output LockableFileWriter LockableFileWriter
public LockableFileWriter(File file, boolean append, String lockDir) throws IOException
From source file:de.ipbhalle.metfrag.tools.Writer.java
/** * Write to file and prevent that this file is overwritten by another thread while writing to it. * /*from w w w. ja v a 2 s. c om*/ * @param file the file * @param content the content * * @throws InterruptedException the interrupted exception */ public static void writeToFile(String file, String content) throws InterruptedException { try { LockableFileWriter lfw = new LockableFileWriter(file, true, "/home/swolf/locks/"); lfw.write(content); lfw.close(); } catch (Exception e) { Thread.sleep(10); writeToFile(file, content); } }