List of utility methods to do Rename File
void | rename(File from, File to) rename ensureFileDoesNotExist(to); if (!from.renameTo(to)) { throw new IOException("Unable to rename " + from + " to " + to); |
void | rename(File from, File to, boolean overwrite) rename boolean success = true; if (!from.exists()) { throw new IOException("file from=[" + from.getAbsolutePath() + "] not exists."); if (to.exists()) { if (overwrite) { success = to.delete(); if (!success) { ... |
void | rename(File oldFile, File newFile) rename rename(oldFile, newFile, false); |
boolean | rename(File pFrom, File pTo) Renames the specified file, if the destination does not exist. return rename(pFrom, pTo, false);
|
boolean | rename(File pFrom, File pTo, boolean pOverWrite) Renames the specified file. if (!pFrom.exists()) { throw new FileNotFoundException(pFrom.getAbsolutePath()); if (pFrom.isFile() && pTo.isDirectory()) { pTo = new File(pTo, pFrom.getName()); return (pOverWrite || !pTo.exists()) && pFrom.renameTo(pTo); |
void | rename(File source, File dest) It seems that java doesn't like renaming files across partitions (i.e. if (!source.renameTo(dest)) { FileInputStream from = null; FileOutputStream to = null; try { from = new FileInputStream(source); to = new FileOutputStream(dest); stream(from, to); } finally { ... |
boolean | rename(File source, File target) rename if (source == null || target == null) { throw new IllegalArgumentException("Input cannot be null."); return source.renameTo(target); |
boolean | rename(File src, File dest) rename if (src.exists()) { return src.renameTo(dest); return false; |
File | rename(File src, String name) Renames a file using a string. File ret = new File(src.getParentFile(), name); if (src.renameTo(ret)) return ret; else return null; |
void | rename(File srcFile, String newName) rename. if (srcFile == null) { throw new NullPointerException("Source must not be null"); if (newName == null || newName.length() == 0) { throw new NullPointerException("newName must not be null"); if (srcFile.exists() == false) { throw new FileNotFoundException("Source '" + srcFile + "' does not exist"); ... |