To migrate any file in Java, in Java 6 or older Java versions, we can use the renameTo() method located in the File object to do this: 
		
		
			
			
			
			
				
					
				|  | package com.huongdanjava.javaexample;   import java.io.File;   public class MoveFile {       public static void main(String[] args) {         File source = new File("F://source.txt");         File dest = new File("E://dest.txt");           if (source.renameTo(dest)) {             System.out.println("Move file " + source.getAbsolutePath() + " to " + dest.getAbsolutePath() + " success.");         }     } } | 
				
			 
		 
 Result: 
		
		
			
			
			
			
				
					
				|  | Move file F:\source.txt to E:\dest.txt success | 
				
			 
		 
 From Java 7 onwards, we have another way to move a file, which is to… Read More