Move File

import java.nio.file.*;
import static java.nio.file.StandardCopyOption.*;

class movefile {
	public static void main(String args[ ]) throws IOException {
		Path success = null;
		File src = new File("/home/user/Documents/abc.txt");

		/* Destination directory */
		File des = new File("/home/user/abc.txt");
		if(Files.isReadable(src.toPath())) {

			/* Move file to new directory */
			success = Files.move(src.toPath(), des.toPath(), REPLACE_EXISTING);
			System.out.println("File successfully move to: "+success);
			System.out.println("File not found!");

File has been deleted successfully!


File not found or not able to deleted!

Learn more about Move File

Recommended for you