利用FileInputStream和FileOutputStreamj进行复制粘贴
/* 文件复制粘贴 */ import java.io.*; public class FileInput_OutputStreamCopy { public static void main(String[] args) throws Exception { //创建输入流 FileInputStream fis = new FileInputStream("FileInput_OutputStreamCopy.java"); //创建输出流 FileOutputStream fos = new FileOutputStream("D:\FileInput_OutputStreamCopy.java"); int temp = 0; byte[] bytes = new byte[1024]; while((temp = fis.read(bytes)) != -1){ //将byte数组中内容直接写入 fos.write(bytes,0,temp); } fos.flush(); fis.close(); fos.close(); } }