use of org.openide.filesystems.FileAlreadyLockedException in project netbeans-mmd-plugin by raydac.
the class AbstractElement method writeMindMap.
protected static void writeMindMap(final File file, final MindMap map) throws IOException {
final FileObject fileObject = FileUtil.toFileObject(file);
FileLock lock = null;
while (true) {
try {
lock = fileObject.lock();
break;
} catch (FileAlreadyLockedException ex) {
delay(500L);
}
}
try {
final OutputStream out = fileObject.getOutputStream(lock);
try {
// NOI18N
IOUtils.write(map.packToString(), out, "UTF-8");
} finally {
IOUtils.closeQuietly(out);
}
} finally {
if (lock != null) {
lock.releaseLock();
}
}
}
Aggregations