private void save(File dir) { File f = new File(dir, MAP_FILE); try { AtomicFileWriter w = new AtomicFileWriter(f); try { for (Map.Entry<String,Integer> entry : idToNumber.entrySet()) { w.write(entry.getKey() + ' ' + entry.getValue() + '\n'); } w.commit(); } finally { w.abort(); } } catch (IOException x) { LOGGER.log(WARNING, "could not save changes to " + f, x); } }
/** * Overwrites the file by the given string. */ public void write(String text) throws IOException { file.getParentFile().mkdirs(); AtomicFileWriter w = new AtomicFileWriter(file); try { w.write(text); w.commit(); } finally { w.abort(); } }
public void write( Object o ) throws IOException { mkdirs(); AtomicFileWriter w = new AtomicFileWriter(file); try { w.write("<?xml version='1.1' encoding='UTF-8'?>\n"); beingWritten.put(o, null); writing.set(file); try { xs.toXML(o, w); } finally { beingWritten.remove(o); writing.set(null); } w.commit(); } catch(RuntimeException e) { throw new IOException(e); } finally { w.abort(); } }
afw.commit(); } finally { afw.abort();
static void writeSymlink(File cache, String target) throws IOException, InterruptedException { LOGGER.log(Level.FINE, "writeSymlink {0} → {1}", new Object[] {cache, target}); synchronized (symlinks) { symlinks.put(cache, target); } StringWriter w = new StringWriter(); StreamTaskListener listener = new StreamTaskListener(w); Util.createSymlink(cache.getParentFile(),target,cache.getName(),listener); // Avoid calling resolveSymlink on a nonexistent file as it will probably throw an IOException: if (!exists(cache) || Util.resolveSymlink(cache)==null) { // symlink not supported. use a regular file AtomicFileWriter cw = new AtomicFileWriter(cache); try { cw.write(target); cw.commit(); } finally { cw.abort(); } } }
out.abort(); // don't leave anything behind
private void save(File dir) { File f = new File(dir, MAP_FILE); try { AtomicFileWriter w = new AtomicFileWriter(f); try { for (Map.Entry<String,Integer> entry : idToNumber.entrySet()) { w.write(entry.getKey() + ' ' + entry.getValue() + '\n'); } w.commit(); } finally { w.abort(); } } catch (IOException x) { LOGGER.log(WARNING, "could not save changes to " + f, x); } }
/** * Overwrites the file by the given string. */ public void write(String text) throws IOException { file.getParentFile().mkdirs(); AtomicFileWriter w = new AtomicFileWriter(file); try { w.write(text); w.commit(); } finally { w.abort(); } }
/** * Overwrites the file by the given string. */ public void write(String text) throws IOException { file.getParentFile().mkdirs(); AtomicFileWriter w = new AtomicFileWriter(file); try { w.write(text); w.commit(); } finally { w.abort(); } }
/** * Overwrites the file by the given string. */ public void write(String text) throws IOException { file.getParentFile().mkdirs(); AtomicFileWriter w = new AtomicFileWriter(file); try { w.write(text); w.commit(); } finally { w.abort(); } }
/** * Overwrites the file by the given string. */ public void write(String text) throws IOException { file.getParentFile().mkdirs(); AtomicFileWriter w = new AtomicFileWriter(file); try { w.write(text); w.commit(); } finally { w.abort(); } }
public void write( Object o ) throws IOException { mkdirs(); AtomicFileWriter w = new AtomicFileWriter(file); try { w.write("<?xml version='1.0' encoding='UTF-8'?>\n"); beingWritten.put(o, null); writing.set(file); try { xs.toXML(o, w); } finally { beingWritten.remove(o); writing.set(null); } w.commit(); } catch(StreamException e) { throw new IOException(e); } finally { w.abort(); } }
/** * Overwrites the file by the given string. */ public void write(String text) throws IOException { file.getParentFile().mkdirs(); AtomicFileWriter w = new AtomicFileWriter(file); try { w.write(text); w.commit(); } finally { w.abort(); IOUtils.closeQuietly(w); } }
static void writeSymlink(File cache, String target) throws IOException, InterruptedException { LOGGER.log(Level.FINE, "writeSymlink {0} → {1}", new Object[] {cache, target}); synchronized (symlinks) { symlinks.put(cache, target); } StringWriter w = new StringWriter(); StreamTaskListener listener = new StreamTaskListener(w); Util.createSymlink(cache.getParentFile(),target,cache.getName(),listener); // Avoid calling resolveSymlink on a nonexistent file as it will probably throw an IOException: if (!exists(cache) || Util.resolveSymlink(cache)==null) { // symlink not supported. use a regular file AtomicFileWriter cw = new AtomicFileWriter(cache); try { cw.write(target); cw.commit(); } finally { cw.abort(); } } }
public void write( Object o ) throws IOException { mkdirs(); AtomicFileWriter w = new AtomicFileWriter(file); try { w.write("<?xml version='1.0' encoding='UTF-8'?>\n"); xs.toXML(o,w); w.commit(); } catch(StreamException e) { throw new IOException2(e); } finally { w.abort(); } }
public void write(Object o) throws IOException { mkdirs(); AtomicFileWriter w = new AtomicFileWriter(file); try { w.write("<?xml version='1.0' encoding='UTF-8'?>\n"); xs.toXML(o, w); w.commit(); } catch (StreamException e) { throw new IOException2(e); } finally { w.abort(); } }
public void write( Object o ) throws IOException { mkdirs(); AtomicFileWriter w = new AtomicFileWriter(file); try { w.write("<?xml version='1.0' encoding='UTF-8'?>\n"); xs.toXML(o,w); w.commit(); } catch(StreamException e) { throw new IOException2(e); } finally { w.abort(); } }
public void write( Object o ) throws IOException { mkdirs(); AtomicFileWriter w = new AtomicFileWriter(file); try { w.write("<?xml version='1.0' encoding='UTF-8'?>\n"); xs.toXML(o,w); w.commit(); } catch(StreamException e) { throw new IOException2(e); } finally { w.abort(); } }
private synchronized void saveToRunMapXml() { if (!isDirty() || persistenceFile == null) { return; } AtomicFileWriter w = null; try { w = new AtomicFileWriter(persistenceFile); w.write("<?xml version='1.0' encoding='UTF-8'?>\n"); xstream.toXML(this, w); w.commit(); markDirty(false); } catch (Exception ex) { LOGGER.log(Level.SEVERE, "Cannot write RunMap.xml", ex); } finally { if ( w != null) { try { w.abort();} catch (IOException ex) {}; } } }