Here you can find the source of renameFile(String oldPath, String newName)
public static void renameFile(String oldPath, String newName)
//package com.java2s; //License from project: Apache License import java.io.*; public class Main { public static void renameFile(String oldPath, String newName) { File file = new File(oldPath); if (!file.exists()) { return; }/*from www .j av a 2 s . co m*/ String newPath = newName; if (file.getParent() != null) { newPath = file.getParent() + File.separator + newName; } file.renameTo(new File(newPath)); } }