java rename file

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

  //...

  Path source = Paths.get("/home/mkyong/newfolder/test1.txt");
  Path target = Paths.get("/home/mkyong/newfolder/test2.txt");

  try{

    Files.move(source, target);

  } catch (IOException e) {
    e.printStackTrace();
  }
Yusuf Solmaz