List of utility methods to do Rename File
void | renameDirectory(String newDir, String oldDir) rename Directory File ofile = new File(oldDir); File nfile = new File(newDir); ofile.renameTo(nfile); |
int | renameExcludedFiles(File existingBinaryFolder, Collection Will attempt to rename each file that is bid.dat where possible bids are passed in the excludedBids collection to bid.exclude. for (int bid : excludedBids) { File oldFile = new File(existingBinaryFolder, bid + "." + BINARY_FILE_EXTENSION); File newFile = new File(existingBinaryFolder, bid + "." + EXCLUDED_BINARY_FILE_EXTENSION); if (!oldFile.renameTo(newFile)) return bid; return -1; |
void | renameExistingWithRetries(final File fromFile, final File toFile) rename Existing With Retries final int MAX_TRIES = 4; final int SLEEP_PER_TRY_MILLIS = 250; renameExistingWithRetries(fromFile, toFile, MAX_TRIES, SLEEP_PER_TRY_MILLIS); |
void | renameFile(File src, File dest) Rename a file. if (dest.exists()) dest.delete(); boolean success = false; for (int i = 0; i < 10; i++) { try { if (i > 0) Thread.sleep(500); } catch (InterruptedException e) { ... |
void | renameFile(String source, String dest) rename File File file = new File(source); file.renameTo(new File(dest)); |
Boolean | renameFile(String sourcePath, String targetPath) rename File File oldFile = new File(sourcePath); File newFile = new File(targetPath); if (oldFile.isFile()) { oldFile.renameTo(newFile); return true; } else { return false; |
boolean | renameFile(String src_pathname, String dest_pathname) rename File File src_file = new File(src_pathname); return src_file.renameTo(new File(dest_pathname)); |
File | renameFileFromChinese(File file) rename File From Chinese String fileName = file.getName(); String extension = getExtension(fileName); String destFileName = fileName.substring(0, fileName.lastIndexOf(File.separator) + 1) + System.currentTimeMillis() + extension; File destFile = new File(destFileName); file.renameTo(destFile); return destFile; |
boolean | renameFileHard(File srcFile, File destFile) rename File Hard boolean isRenamed = false; if (srcFile != null && destFile != null) { if (!destFile.exists()) { if (srcFile.isFile()) { FileInputStream in = null; FileOutputStream out = null; try { in = new FileInputStream(srcFile); ... |
File | renameFileIfExists(File f) * If the file f already exists, this method returns a new File object with a unique name formed by appending an integer. File result = f; try { String canonicalPath = result.getCanonicalPath(); int lidx = canonicalPath.lastIndexOf("."); String suff = ""; String base = canonicalPath; if (lidx != -1) { suff = canonicalPath.substring(lidx); ... |