Here you can find the source of renameFile(File sourceFile, String newFileName)
public static void renameFile(File sourceFile, String newFileName)
//package com.java2s; import java.io.File; public class Main { public static void renameFile(File sourceFile, String newFileName) { File targetFile = new File(sourceFile.getParent(), newFileName); sourceFile.renameTo(targetFile); }//from w w w . j a va 2 s . c o m }