标题: 关于IO中的flush问题求教 [打印本页] 作者: 疯狂的大猫 时间: 2015-6-9 22:51 标题: 关于IO中的flush问题求教 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);