package ioliu; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; public class Fuzhi { public static void main(String[] args) { //文件复制 //1.边读边写 try { //读 输入流 FileInputStream in = new FileInputStream("e:/1.docx") ; // byte[ ] b = new byte[1024] ; int i = -1 ; //写 输出流 FileOutputStream out = new FileOutputStream("d:/123付士亮.docx") ; //边读边写 while((i=in.read(b))>0) { // 写 out.write( b, 0 , i); } out.close(); in.close(); System.out.println("复制成功!"); } catch (Exception e) { e.printStackTrace(); } } }