Here you can find the source of renameDirectory(File directory, File newDirectory)
public static boolean renameDirectory(File directory, File newDirectory)
//package com.java2s; //License from project: Open Source License import java.io.File; public class Main { public static boolean renameDirectory(File directory, File newDirectory) { try {/*from w w w .j av a 2 s .c o m*/ if (directory.isDirectory()) { directory.renameTo(newDirectory); } else { directory.mkdir(); directory.renameTo(newDirectory); } return true; } catch (Exception ex) { return false; } } }