List of usage examples for java.io File renameTo
public boolean renameTo(File dest)
From source file:Main.java
public static boolean rename(String filepath, String newName) { File file = new File(filepath); return file.exists() && file.renameTo(new File(newName)); }
From source file:Main.java
public static boolean renameFile(String oldPath, String newPath) { File fOld = new File(oldPath); File fNew = new File(newPath); return fOld.renameTo(fNew); }
From source file:Main.java
public static void RenameFileToOldPath(String newpath) { String path = newpath;// w ww . j ava 2s.com String old = path + ".ck"; File sdcard = Environment.getExternalStorageDirectory(); File from = new File(sdcard, newpath); File to = new File(sdcard, old); from.renameTo(to); }
From source file:Main.java
static public boolean renameFile(File file, File new_name) { boolean result; if (file != null && file.exists() && file.renameTo(new_name)) { result = true;/*from w w w .j av a2 s.c o m*/ } else { result = false; } return result; }
From source file:Main.java
/** * Moves a file to another location./*from w ww . j a va 2 s . com*/ */ public static void move(File from, File to) { if (!from.renameTo(to)) { copyFile(from, to); if (!from.delete()) { if (!to.delete()) { throw new RuntimeException("Unable to delete " + to); } throw new RuntimeException("Unable to delete " + from); } } }
From source file:Main.java
public static String RenameFileToNewPath(String oldpath) { String path = oldpath;/* w w w.j ava 2s .c o m*/ path = path.replace("/mnt/sdcard/", ""); String new_path = path.replace(".ck", ""); File sdcard = Environment.getExternalStorageDirectory(); File from = new File(sdcard, oldpath); File to = new File(sdcard, new_path); from.renameTo(to); return to.toString(); }
From source file:com.lixiaocong.util.VideoFileHelper.java
public static boolean moveFiles(List<File> files, String destPath) { File dir = new File(destPath); if (!dir.isDirectory()) return false; boolean ret = true; for (File file : files) { if (!file.renameTo(new File(destPath + file.getName()))) { ret = false;//from w w w . j av a2 s. c om logger.error("move " + file.getName() + " error"); } } return ret; }
From source file:com.frederikam.fredboat.bootloader.Bootloader.java
private static void update() { //The main program has already prepared the shaded jar. We just need to replace the jars. File oldJar = new File("./" + jarName); oldJar.delete();// ww w.ja va 2s . c o m File newJar = new File("./update/target/" + jarName); newJar.renameTo(oldJar); //Now clean up the workspace boolean deleted = new File("./update").delete(); System.out.println("[BOOTLOADER] Updated. Update dir deleted: " + deleted); }
From source file:Main.java
public static void deleteLastSuffix(String filePath) { System.out.println("deleteSuffix"); File file = new File(filePath); String newFilePath = filePath.substring(0, filePath.lastIndexOf(".")); file.renameTo(new File(newFilePath)); }
From source file:com.jcalvopinam.core.Unzipping.java
private static void renameFinalFile(CustomFile customFile, String fileNameOutput) { File output = new File(fileNameOutput); output.renameTo(new File(customFile.getPath() + customFile.getFileName())); }