Java I/O How to - Resolve Sibling during file moving with java.nio.file.Files


We would like to know how to resolve Sibling during file moving with java.nio.file.Files.


import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
/*from   w ww . j a va  2  s  .c om*/
public class Main {

  public static void main(String[] args) throws Exception{
    Path sourceFile = Paths.get("C:/home/docs/users.txt");
    Files.move(sourceFile, sourceFile.resolveSibling(sourceFile.getFileName() + ".bak"));