mardi 30 juin 2015

Can LockableFileWriter class in Apache Commons Library be used to perform an exclusive write operation through a java program?

Will the following snippet of code prevent concurrent writes through the java program?

Here is the Javadoc for LockableFileWriter class: http://ift.tt/1T4EgNY

Here is the Javadoc for IOUtils: http://ift.tt/1GJrv4H

File file = new File(fileName);
     LockableFileWriter writer = new LockableFileWriter(file,true);
     writer.flush();
     org.apache.commons.io.IOUtils.writeLines(lines,"\n",writer);
     writer.close();

Aucun commentaire:

Enregistrer un commentaire