读写非文本文件--IO流

来源:互联网 发布:友盟推送 php服务器端 编辑:程序博客网 时间:2024/05/29 10:06
public void rw2(){
    BufferedInputStream bis=null;
    BufferedOutputStream bos=null;
    byte[] by=new byte[1024];
    int len=0;
    try {
bis=new BufferedInputStream(new FileInputStream(new File("F:/临时下载的文件/freemarker/1_freemarker入门_第一个freemarker程序.flv")));
bos=new BufferedOutputStream(new FileOutputStream(new File("F:/tt/1.flv")));
while((len=bis.read(by))!=-1){
bos.write(by, 0, len);
bos.flush();
}
} catch (Exception e) {
e.printStackTrace();
}finally {
if(bos!=null){
try {
bos.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if(bis!=null){
try {
bis.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
    }
原创粉丝点击