Mover fichero de un directorio a otro en Java


import java.io.File;
 
public class rename_fichero {
    public static void main(String args[]) throws java.io.IOException {
            File fichero = new File("datos.txt");
 
            File fichero2 = new File("datos.csv");
 
            boolean success = fichero.renameTo(fichero2);
            if (!success) {
                System.out.println("Error intentando cambiar el nombre de fichero");
            }
    }
}