A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© YLJNHKKD 中级黑马   /  2018-11-29 14:34  /  568 人查看  /  0 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文



1、InputStream抽象类:继承自InputStream的流都是用于向程序中输入数据的,且数据的单位为字节(8位)。

InputStream的基本方法:
public abstract int read() throws IOException {}//从输入流中读取数据的下一个字节, 返回读到的字节值.若遇到流的末尾,返回-1
public int read(byte[] b) throws IOException {}//从输入流中读取 b.length 个字节的数据并存储到缓冲区数组b中.返回的是实际读到的字节总数
public int read(byte[] b, int off, int len) throws IOException {}//读取 len 个字节的数据,并从数组b的off位置开始写入到这个数组中
public void close() throws IOException {}//关闭此输入流并释放与此流关联的所有系统资源
public int available() throws IOException {}//返回此输入流下一个方法调用可以不受阻塞地从此输入流读取(或跳过)的估计字节数
public long skip(long n) throws IOException {}//跳过和丢弃此输入流中数据的 n 个字节,返回实现路过的字节数。
1234567

2、OutputStream抽象类:继承自OutputStream的流是程序用于向外输出数据的,且数据的单位为字节(8位)。

OutputStream的基本方法:
public abstract void write(int b) throws IOException {}//将指定的字节写入此输出流。
public void write(byte[] b) throws IOException {}// 将 b.length 个字节从指定的 byte 数组写入此输出流。
public void write(byte[] b, int off, int len) throws IOException {}//将指定 byte 数组中从偏移量 off 开始的 len 个字节写入此输出流。
public void flush() throws IOException {}//刷新此输出流并强制写出所有缓冲的输出字节。
pulbic void close() throws IOException {}//关闭此输出流并释放与此流有关的所有系统资源。
123456

3、Reader抽象类:继承自Reader的流都是用于向程序中输入数据的,且数据的单位为字符(16位)。

Reader的基本方法:
public int read() throws IOException {}//读取单个字符,返回作为整数读取的字符,如果已到达流的末尾返回-1
public int read(char[] cbuf) throws IOException {}//将字符读入数组,返回读取的字符数
public abstract int read(char[] cbuf, int off, int len) throws IOException {}//读取 len 个字符的数据,并从数组cbuf的off位置开始写入到这个数组中
public abstract void close() throws IOException {}//关闭该流并释放与之关联的所有资源
public long skip(long n) throws IOException {}//跳过n个字符。
public int available()  //还可以有多少能读到的字节数
1234567

4、Writer抽象类:继承自Writer的流是程序用于向外输出数据的,且数据的单位为字符(16位)。

Writer的基本方法:
public void write(int c) throws IOException {} //写入单个字符
public void write(char[] cbuf) throws IOException {} //写入字符数组
public abstract void write(char[] cbuf, int off, int len) throws IOException {} //写入字符数组的某一部分
public void write(String str) throws IOException {} //写入字符串
public void write(String str, int off, int len) throws IOException {}//写字符串的某一部分
public abstract void close() throws IOException {}  //关闭此流,但要先刷新它
public abstract void flush() throws IOException {}  //刷新该流的缓冲,将缓冲的数据全写到目的地
---------------------
作者:PennTsui
来源:CSDN
原文:https://blog.csdn.net/SilenceOO/article/details/50995062
版权声明:本文为博主原创文章,转载请附上博文链接!

0 个回复

您需要登录后才可以回帖 登录 | 加入黑马