复制一个文件
package bianchengti; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; /* * 复制一个文件 */ public class FileCopy { public static void main(String[] args) throws IOException { // TODO Auto-generated method stub FileInputStream fis = new FileInputStream("e:/a.txt"); FileOutputStream fos =new FileOutputStream("e:/b.txt"); byte[] buff = new byte[256]; int len = 0; while((len = fis.read(buff))>0) { fos.write(buff,0,len); } System.out.println("复制完成"); fis.close(); fos.close(); } }
追梦的脚步,永不停息