復制一個文件
阿新 • • 發佈:2017-09-29
cheng generate div nbsp oid 復制 out stub clas
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(); } }
復制一個文件