Here you can find the source of rename(File source, File target)
public static boolean rename(File source, File target)
//package com.java2s; /*//www. ja va2s.c o m * This software is distributed under the terms of the FSF * Gnu Lesser General Public License (see lgpl.txt). * * This program is distributed WITHOUT ANY WARRANTY. See the * GNU General Public License for more details. */ import java.io.File; public class Main { public static boolean rename(File source, File target) { if (source == null || target == null) { throw new IllegalArgumentException("Input cannot be null."); } return source.renameTo(target); } public static boolean rename(String parentPathAbsolute, String oldName, String newName) { boolean status = false; File oldFile = new File(parentPathAbsolute + File.separatorChar + oldName); status = oldFile.renameTo(new File(parentPathAbsolute + File.separatorChar + newName)); return status; } }