java拷贝文件

package com.zuidaima.util.file;

import java.io.File;

public class CopyFile {

	public static void main(String[] args) {
		try {
			File file = new File("C:\\123.txt");
			if (afile.renameTo(new File("C:\\123\\" + file.getName()))) {
				System.out.println("File is moved successful!");
			} else {
				System.out.println("File is failed to move!");
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
	    			

你可能感兴趣的:(java)