java_IO流总结

java_IO流总结

ID:37711403

大小:30.22 KB

页数:8页

时间:2019-05-29

java_IO流总结_第1页
java_IO流总结_第2页
java_IO流总结_第3页
java_IO流总结_第4页
java_IO流总结_第5页
资源描述:

《java_IO流总结》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、********************************第19天IO流*************************************************************基本内容*****************************字符流:Reader常用子类:InputStreamReader->(继承)FileReader,BufferedReaderWriter常用子类:OutputStreamWriter->(继承)FileWriter,BufferedWriter字节流:OutputStream常用子类:File

2、OutputStream,DataOutputStream,ObjectOutputStream,BufferedOutputStream,ByteArrayOutputStreamInputStream常用子类:FileInputStream,DataInputStream,ObjectOutputStream,BufferedInputStream,ByteArrayInputStream打印流:PrintStream常用子对象:System.out,System.in,System.err===============================

3、===============================================================********************************字节流:OutputStream,InputStream********************************一、字节流:FileInputStream,FileInputStream//文件读写importjava.io.*;publicclassText1{publicstaticvoidmain(String[]args){FileInputStream

4、fis=null;FileInputStreamfos=null;try{fis=newFileInputStream("e:\temp\from.zip");fos=newFileOutputStream("e:\temp\to.zip");byte[]buffer=newbyte[1024];while(true){inttemp=fis.read(buffer,0,buffer.length);if(temp==-1){break;}fos.write(buffer,0,temp);}}catch(Exceptione){e.printSta

5、ckTrace();}finally{try{//捕获io流关闭异常fis.close();fos.close();}catch(Exceptione2){}}}}二、字节缓冲流:BufferedInputStream,BufferedOutputStream--------------------------------------//文件读写publicclassText2{publicstaticvoidmain(String[]args){StringfileName="e:\老罗视频Android01-09.zip";StringtoName=

6、"e:\temp\老罗视频Android01-09.zip";FileInputStreamfis=null;FileOutputStreamfos=null;BufferedInputStreambis=null;BufferedOutputStreambos=null;try{fis=newFileInputStream(fileName);fos=newFileOutputStream(toName);bis=newBufferedInputStream(fis);bos=newBufferedOutputStream(fos);longtime

7、1=System.currentTimeMillis();//打印时间while(true){byte[]buffer=newbyte[1024];inttemp=bis.read(buffer,0,buffer.length);if(temp==-1){break;}bos.write(buffer,0,temp);}longtime2=System.currentTimeMillis();System.out.println((time2-time1)/60000);//求时间差}catch(IOExceptione){e.printStackTrac

8、e();}finally{try{bis.close();bos.

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。