使用字節(jié)流拷貝一個(gè)文本文件?
import java.io.*; public class FileCopyDemo{ public static void main(String[] args)throws IOException{ FlileInputStream read = new FileInputStream(new File("D:\1.txt"))
; FileOutputStream write = new FileOutputStream(new File("D:\copy.txt"))
; byte[] b = new byte[1024]; int len = 0; while((len=read.read(b))!=-1){ write(read,0,len)
; write.flush(); } write.close(); read.close(); } }