Java tutorial
//package com.java2s; //License from project: Open Source License import java.io.File; public class Main { public static void rename(String oldPath, String newPath) { File oldFile = new File(oldPath); File newFile = new File(newPath); if (oldFile.exists()) oldFile.renameTo(newFile); // if (!KCNativeUtil.renameExt(oldPath, newPath)) { // File oldFile = new File(oldPath); // try { // InputStream is = new FileInputStream(oldFile); // OutputStream os = new FileOutputStream(oldPath); // byte[] buffer = getThreadSafeByteBuffer(); // // int lenRead; // while ((lenRead = is.read(buffer)) != -1) { // os.write(buffer, 0, lenRead); // } // // is.close(); // os.close(); // // if (oldFile.exists()) // oldFile.delete(); // } catch (Exception e) { // e.printStackTrace(); // } finally { // } // } } }