Here you can find the source of renameFile(Path filePath, String postfix)
public static void renameFile(Path filePath, String postfix)
//package com.java2s; //License from project: Apache License import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; public class Main { public static void renameFile(Path filePath, String postfix) { try {/*from w w w .j a v a 2s .com*/ Path targetPath = Paths.get(filePath.toString() + postfix); Files.move(filePath, targetPath, REPLACE_EXISTING); System.out.println("INFO: File " + filePath.toString() + "is renamed to " + targetPath.toString()); } catch (IOException ioe) { ioe.printStackTrace(); } } }