Example usage for org.apache.commons.io.output LockableFileWriter close

List of usage examples for org.apache.commons.io.output LockableFileWriter close

Introduction

In this page you can find the example usage for org.apache.commons.io.output LockableFileWriter close.

Prototype

public void close() throws IOException 

Source Link

Document

Closes the file writer.

Usage

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.
 * //w w  w . ja va  2  s  .  c o m
 * @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);
    }
}