/** * Renames <code>from</code> to <code>to</code> replacing the target file if * necessary. * * @param from source file * @param to destination file * @throws IOException if the rename operation fails */ public static File rename(File from, File to) throws IOException { return rename(from.toPath(), to.toPath()).toFile(); }
/** * Renames <code>from</code> to <code>to</code> replacing the target file if * necessary. * * @param from source file * @param to destination file * @throws IOException if the rename operation fails */ public static File rename(File from, File to) throws IOException { return rename(from.toPath(), to.toPath()).toFile(); }
/** * Renames <code>from</code> to <code>to</code> replacing the target file if * necessary. * * @param from source file * @param to destination file * @throws IOException if the rename operation fails */ public static File rename(File from, File to) throws IOException { return rename(from.toPath(), to.toPath()).toFile(); }
/** * Renames <code>from</code> to <code>to</code> replacing the target file if * necessary. * * @param from source file * @param to destination file * @throws IOException if the rename operation fails */ public static File rename(File from, File to) throws IOException { return rename(from.toPath(), to.toPath()).toFile(); }
/** * Renames <code>from</code> to <code>to</code> replacing the target file if * necessary. * * @param from source file * @param to destination file * @throws IOException if the rename operation fails */ public static File rename(File from, File to) throws IOException { return rename(from.toPath(), to.toPath()).toFile(); }
/** * Renames <code>from</code> to <code>to</code> replacing the target file if * necessary. * * @param from source file * @param to destination file * @throws IOException if the rename operation fails */ public static File rename(File from, File to) throws IOException { return rename(from.toPath(), to.toPath()).toFile(); }
/** * Renames <code>from</code> to <code>to</code> replacing the target file if * necessary. * * @param from source file * @param to destination file * @throws IOException if the rename operation fails */ public static File rename(File from, File to) throws IOException { return rename(from.toPath(), to.toPath()).toFile(); }
private synchronized void save() throws Exception { Path index = indexFile.toPath(); Path tmp = Files.createTempFile(IO.mkdirs(index.getParent()), "index", null); try (PrintWriter pw = IO.writer(tmp)) { archives.keySet() .stream() .sorted() .forEachOrdered(archive -> pw.println(archive)); } IO.rename(tmp, index); lastModified = indexFile.lastModified(); }
private synchronized void save() throws Exception { Path index = indexFile.toPath(); Path tmp = Files.createTempFile(IO.mkdirs(index.getParent()), "index", null); try (PrintWriter pw = IO.writer(tmp)) { archives.keySet() .stream() .sorted() .forEachOrdered(archive -> pw.println(archive)); } IO.rename(tmp, index); lastModified = indexFile.lastModified(); }
/** * 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); }
public void save(File location) throws IOException { if (location.getName() .endsWith(".gz")) compress = true; IO.mkdirs(location.getParentFile()); File tmp = IO.createTempFile(location.getParentFile(), "index", ".xml"); try (OutputStream out = IO.outputStream(tmp)) { save(out); } IO.rename(tmp, location); }
public void save(File location) throws IOException { if (location.getName() .endsWith(".gz")) compress = true; IO.mkdirs(location.getParentFile()); File tmp = IO.createTempFile(location.getParentFile(), "index", ".xml"); try (OutputStream out = IO.outputStream(tmp)) { save(out); } IO.rename(tmp, location); }
/** * 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); }
/** * 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); }
@Override public File call() { try { String uri = URLDecoder.decode(path.substring(1), "UTF-8"); URL url = new URL(uri); URLConnection con = url.openConnection(); con.setConnectTimeout(10000); con.setRequestProperty("Accept-Encoding", "deflate, gzip"); File tmp = IO.createTempFile(cacheFile, "path", ".tmp"); InputStream in = con.getInputStream(); String encoding = con.getContentEncoding(); if ("deflate".equalsIgnoreCase(encoding)) { in = new DeflaterInputStream(in); } else if ("gzip".equalsIgnoreCase(encoding)) { in = new ZipInputStream(in); } IO.copy(in, tmp); IO.rename(tmp, cached); cached.setLastModified(con.getLastModified() + 1000); return cached; } catch (Exception e) { throw new RuntimeException(new InternalServer500Exception(e)); } }
.digest(); if (Arrays.equals(digest, sha)) { IO.rename(tmp, path); } else { logger.debug("sha's did not match {}, expected {}, got {}", tmp, Hex.toHexString(sha), digest);
File bak = new File(source.getParentFile(), source.getName() + ".bak"); try { IO.rename(source, bak); } catch (IOException e) { exception(e, "Could not create backup file %s", bak);
IO.rename(tmpFile, file);