public static void copyFile(String src,String dest)throws IOException{
BufferedWriter bw = new BufferedWriter(new FileWriter(dest));
BufferedReader br = new BufferedReader(new FileReader(src));
char[] chs = new char[1024];
int len =0;
while((len=br.read(chs)) !=-1){
bw.write(chs,0,len);
bw.flush();
}
br.close();
bw.close();
}
public static void copyBinaryDate(String src,String dest) throws IOException{
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(src));
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(dest));
byte[] bys =new byte[1024];
int len =0;
while((len = bis.read(bys)) !=-1){
bos.write(bys,0,len);
bis.close();
bos.close();
}
}
}
为什么我上面那个类中要flush,而下面这个二进制复制的类可以不要flush啊??? |
|