In this section we will be showing on how to move a file  or directory from one folder to another in java.  The sample source uses the renameTo method under the File class of package.

package com.javatutorialhq.tutorial;

 * This java sample code shows how to
 * move file or directory in java
 * demonstrating use of renameTo method
 * Property of
 * All Rights Reserved
 * Version 1.0
 * 06/30/2012

public class MovieFileIO {

	 * @param args
	public static void main(String[] args) {
		File fSource = new File("C:\\temp\\source");
		File fTarget = new File("C:\\temp\\target");
		boolean testSuccess = fSource.renameTo(fTarget);
			System.out.println("Rename succeeded");
			System.out.println("Rename failed");