欢迎来到天天文库
浏览记录
ID:56531340
大小:135.00 KB
页数:20页
时间:2020-06-27
《自学课件二进制.ppt》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、Java程序设计第18章二进制I/O学习目标理解输入和输出流理解字节流和字符流掌握使用文件流读写文件掌握缓冲流了解数据流掌握对象流和对象序列化了解RandomAccessFile输入输出java.io包以流(stream)定义输入/输出。java.io包中的流主要分为字节流:以8位字节形式读写(InputStream/OutputStream)字符流:以16位字符形式读写(Reader/Writer)。信息源程序(读)或Reader目的地程序(写)InputStreamOutputStream或Writeropenastreamwhilemoreinfo
2、rmation{readinformation}closethestreamopenastreamwhilemoreinformation{writeinformation}closethestream字节流InputStreamFileInputStreamPipedInputStreamFilterInputStreamByteArrayInputStreamSequenceInputStreamDataInputStreamBufferedInputStreamOutputStreamObjectInputStreamFileOutputStrea
3、mPipedOutputStreamFilterOutputStreamByteArrayOutputStreamObjectOutputStreamBufferedOutputStreamPrintStreamPushbackInputStreamDataOutputStreamInputStreampublicintread()publicintread(byteb[])publicintread(byteb[],intoffset,intlength)publicintavailable()publiclongskip(longn)publicbo
4、oleanmarkSupported()publicvoidmark(intreadlimit)publicvoidreset()publicvoidclose()Example:CountBytes.javaOutputStreampublicvoidwrite(intb)publicvoidwrite(byteb[])publicvoidwrite(byteb[],intoffset,intlength)publicvoidflush()throwsIOExceptionpublicvoidclose()throwsIOExceptionExampl
5、e:CopyBytes.java字符流ReaderBufferedReaderCharArrayReaderInputStreamReaderFilterReaderPipedReaderStringReaderLineNumberReaderFileReaderPushbackReaderWriterBufferedWriterCharArrayWriterOutputStreamWriterFilterWriterPipedWriterStringWriterFileWriterPrintWriterReaderpublicintread()publ
6、icintread(charbuf[])publicintread(charbuf[],intoffset,intlength)publicbooleanready()publiclongskip(longn)publicbooleanmarkSupported()publicvoidmark(intreadAheadLimit)publicvoidreset()publicabstractvoidclose()Example:CountSpace.javaWriterpublicvoidwrite(intc)publicvoidwrite(charbu
7、f[])publicvoidwrite(charbuf[],intoffset,intlength)publicvoidwrite(Stringstr)publicvoidwrite(Stringstr,intoffset,intlength)publicWriterappend(CharSequencecsq)publicWriterappend(CharSequencecsq,intstart,intend)publicWriterappend(charc)publicabstractvoidflush()publicabstractvoidclos
8、e()Example:Copy.java流类汇总字符字节读写读写数组CharAr
此文档下载收益归作者所有