Here you can find the source of renameTo(File from, File to, boolean deleteDestination)
public static void renameTo(File from, File to, boolean deleteDestination) throws IOException
//package com.java2s; //License from project: Apache License import java.io.File; import java.io.IOException; public class Main { public static void renameTo(File from, File to, boolean deleteDestination) throws IOException { if (deleteDestination) { deleteIfExists(to);/*from w w w .j ava 2s . c o m*/ } if (!from.renameTo(to)) { throw new IOException(); } } public static void deleteIfExists(File file) throws IOException { if (file.exists() && !file.delete()) { throw new IOException("delete failed"); } } }