List of utility methods to do File Rename
void | renameFile(File file, String ext) rename File if (!file.exists()) { return; File dest = new File(file.getParent(), file.getName() + ext); boolean success = file.renameTo(dest); if (success) { System.out.println("[INFO] Rename Session LOG " + dest); } else { ... |
File | renameFile(File file, String name) rename File String filePath = file.getAbsolutePath(); String fileName = file.getName(); String newFilePath = filePath.substring(0, filePath.length() - fileName.length()) + name; File newFile = new File(newFilePath); file.renameTo(newFile); return newFile; |
boolean | renameFile(File file, String newFilename) rename File if (file.exists() == false) return false; String path = file.getPath(); File new_file = new File(path + File.separator + newFilename); return file.renameTo(new_file); |
void | renameFile(File file, String newName) rename File file.renameTo(new File(newName));
|
File | renameFile(File file, String newName) TODO if (file.exists()) { File dest = new File(file.getParentFile(), newName); if (file.renameTo(dest)) { return dest; return null; |
File | renameFile(File file, String newName) rename File String properPath = file.getPath().substring(0, file.getPath().lastIndexOf(File.separator)); String newNameWithoutExt = newName.substring(0, newName.lastIndexOf(".") == -1 ? newName.length() : newName.lastIndexOf(".")); return new File((properPath + File.separator + newNameWithoutExt + ".srt").replaceAll("\\s", "_")); |
void | renameFile(File file, String newName) rename File if (file == null) throw new NullPointerException("file must not be null"); if (!file.isFile() || !file.exists()) throw new IllegalArgumentException("file must not be a file and exists"); File newFile = new File(file.getParent() + "/" + newName); file.renameTo(newFile); |
void | renameFile(File file, String sign, String suffix) rename File String name = file.getAbsolutePath(); int index = name.lastIndexOf(suffix); String newName = name.substring(0, index) + "_" + sign + name.substring(index, name.length()); file.renameTo(new File(newName)); |
void | renameFile(File source, File dest) Traduction to file source.renameTo(dest); |
void | renameFile(File sourceFile, String newFileName) rename File File targetFile = new File(sourceFile.getParent(), newFileName);
sourceFile.renameTo(targetFile);
|