Here you can find the source of renameTo(File currentFile, String newName)
Parameter | Description |
---|---|
currentFile | file to rename |
newName | rename to this (same directory) |
public static void renameTo(File currentFile, String newName)
//package com.java2s; //License from project: Open Source License import java.io.*; import com.google.common.io.Files; public class Main { /**//from w w w. ja v a 2 s. c om * Platform independent rename function * * @param currentFile file to rename * @param newName rename to this (same directory) */ public static void renameTo(File currentFile, String newName) { try { File newFile = new File(newName); Files.move(currentFile, newFile); } catch (IOException e) { e.printStackTrace(); } } }