/** * Save the index file. * * @throws Exception */ private void save() throws Exception { if (!dirty) return; File tmp = new File(indexFile.getAbsolutePath() + ".tmp"); tmp.getParentFile().mkdirs(); PrintWriter ps = new PrintWriter(tmp, "UTF-8"); try { Formatter frm = new Formatter(ps); getIndex().write(frm); frm.close(); } finally { ps.close(); } IO.rename(tmp, indexFile); }
/** * Save the index file. * * @throws Exception */ private void save() throws Exception { if (!dirty) return; File tmp = new File(indexFile.getAbsolutePath() + ".tmp"); tmp.getParentFile().mkdirs(); PrintWriter ps = new PrintWriter(tmp, "UTF-8"); try { Formatter frm = new Formatter(ps); getIndex().write(frm); frm.close(); } finally { ps.close(); } IO.rename(tmp, indexFile); }
/** * Save the index file. * * @throws Exception */ private void save() throws Exception { if (!dirty) return; Path index = indexFile.toPath(); Path tmp = Files.createTempFile(IO.mkdirs(index.getParent()), "index", null); try (PrintWriter ps = IO.writer(tmp); Formatter frm = new Formatter(ps)) { getIndex().write(frm); } IO.rename(tmp, index); }
/** * Get the index, load it if necessary * * @throws Exception */ private FileLayout getIndex() throws Exception { if (index != null) return index; if (!indexFile.isFile()) { return index = new FileLayout(); } else return index = codec.dec() .from(indexFile) .get(FileLayout.class); }
/** * Get the index, load it if necessary * * @return * @throws Exception */ private FileLayout getIndex() throws Exception { if (index != null) return index; if (!indexFile.isFile()) { return index = new FileLayout(); } else return index = codec.dec().from(indexFile).get(FileLayout.class); }
/** * Get the index, load it if necessary * * @throws Exception */ private FileLayout getIndex() throws Exception { if (index != null) return index; if (!indexFile.isFile()) { return index = new FileLayout(); } else return index = codec.dec() .from(indexFile) .get(FileLayout.class); }
/** * Get the index, load it if necessary * * @return * @throws Exception */ private FileLayout getIndex() throws Exception { if (index != null) return index; if (!indexFile.isFile()) { return index = new FileLayout(); } else return index = codec.dec().from(indexFile).get(FileLayout.class); }
/** * Save the index file. * * @throws Exception */ private void save() throws Exception { if (!dirty) return; Path index = indexFile.toPath(); Path tmp = Files.createTempFile(IO.mkdirs(index.getParent()), "index", null); try (PrintWriter ps = IO.writer(tmp); Formatter frm = new Formatter(ps)) { getIndex().write(frm); } IO.rename(tmp, index); }