Java Path File Name nio renameFile(Path filePath, String postfix)

Here you can find the source of renameFile(Path filePath, String postfix)

Description

rename File

License

Apache License

Declaration

public static void renameFile(Path filePath, String postfix) 

Method Source Code

//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();
        }
    }
}

Related

  1. makeUnique(Path basePath, String baseName)
  2. pathToPackageName(Path path)
  3. readFileFromPath(String filename)
  4. relativizePath(Path relativeTo, String filename)
  5. rename(Path origin, Path destination)
  6. renameLogFile(Path original)
  7. saveFileFromByteArray(String filename, String pathDirectory, byte[] data)
  8. saveNamesToFile(Map namesMap, Path namesFile)
  9. saveToFile(String content, String directoryPath, String filename)