Here you can find the source of rename(String fileName, String distFile)
public static boolean rename(String fileName, String distFile)
//package com.java2s; //License from project: Apache License import java.io.*; public class Main { public static boolean rename(String fileName, String distFile) { synchronized (fileName) { File oldFile = new File(fileName); if (oldFile.exists()) { try { oldFile.renameTo(new File(distFile)); return true; } catch (Exception e) { e.printStackTrace(); return false; }/*from w w w . j a v a 2 s. c o m*/ } else { return true; } } } }