Here you can find the source of renameFile(File file, String newName)
public static void renameFile(File file, String newName)
//package com.java2s; //License from project: Apache License import java.io.File; public class Main { public static void renameFile(File file, String newName) { if (file == null) throw new NullPointerException("file must not be null"); if (!file.isFile() || !file.exists()) throw new IllegalArgumentException("file must not be a file and exists"); File newFile = new File(file.getParent() + "/" + newName); file.renameTo(newFile);/*from w w w . jav a 2s . c o m*/ } }