public class Test{

public static void main(String[] args) throws IOException{
FileInputStream in = null;
BufferedInputStream bis =null;
FileOutputStream out =null;
BufferedOutputStream bos =null;
try {
in=new FileInputStream("c:/123/666.doc");
bis=new BufferedInputStream(in);

out=new FileOutputStream("c:/123/999.doc");
bos = new BufferedOutputStream(out);
int len =0;
byte[] buffer = new byte[1024];
while((len=bis.read(buffer))!=-1){
bos.write(buffer, 0, len);
// bos.write(buffer);
}
}
catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}finally{

bos.flush();    //清空缓存写入数据
bos.close();   //一定要关闭流否则文档打开不了
out.close();
bis.close();
in.close();
}

}

相关文章:

  • 2021-05-18
  • 2022-01-06
  • 2021-12-21
  • 2021-12-17
  • 2022-12-23
  • 2022-02-16
  • 2022-12-23
  • 2021-04-01
猜你喜欢
  • 2021-12-07
  • 2022-12-23
  • 2022-12-23
  • 2021-09-29
  • 2021-09-18
  • 2022-02-12
相关资源
相似解决方案