Java I/O_FilterInputStream类
下面4个类都是从FilterInputStream派生来的,具体说明如下。
①BufferedInputStream
从硬盘往一个内存缓冲区进行初始读操作,缓冲区长度默认为 2KB字节,也可以通过入口参数指定缓冲区长度。
②LineNumberInputStream
这个类用来建立带有行计数功能的过滤输入流,还提供一系列与读操作有关的功能。
③PushbackInputStream
这个类用来建立一种特殊的过滤流,它提供一种特殊的方法,即可以把已经读取的一 个字节“推回”到输入流中。用户编写的程序一般很少有这种需求,但是,在编译程序中常常 需要这种操作。因为在编译程序词法分析时,通常需要多读入一个字节以确定词性,然后, 又必须将此多读的字节退回去。所以,对于设计编译程序的计算机系统设计人员来讲,这个子类无疑为其提供极大方便。
上述方法中,第1个是构造方法;第2~5个方法和其它子类的相应方法功能相同;第 6个方法unread(int ch)的功能是将刚刚读取的一个字节退回输入流。
④DataInputStream
用这个类建立的过滤流提供一些基于多字节的读取方法,从而可以读取基本类型的数 据,如布尔量、整型数、浮点数等。使用这些方法的原则是必须预先知道数据类型,这样, 才可调用相应的方法来读取
1 public BufferedInputStream(InputStream in); //
2 public BufferedInputStream(InputStream in,int size);//
3 public int available(); //
4 public void mark(int readlimit); //
5 public boolean markSupported(); //
6 public int read();
7 public int read(byte b[],int off,int len);
8 public void reset(); //
9 public long skip(long n);//
1 public LineNumberInputStream(InputStream in); //
2 public int available(); //
3 public int getLineNumber(); //
4 public void mark(int readlimit); //
5 public int read();
6 public int read(byte b[],int off,int len);
7 public void reset(); //
8 public void setLineNumber(int lineNumbr);//将当前行号设置为指定值
9 public long skip(long n);//
1 public PushbackInputStream(InputStream in);
2 public int available();
3 public boolean markSupported();
4 pubhc int read();
5 public int read(byte b[],int off,int len);
6 public void unread(int ch);
1 public DataInputStream(InputStream in);
2 public final int read(byte b[])throws IOException;
3 public final int read(byte b[],int off,int len)throws IOException;
4 public final void readFully(byte b[])throws IOException;//读取输入流中的数据,直到装满整个数组
5 public final void readFully(byte b[],int off,int len)throws IOException; //装
6 public final int skipBytes(int n)throws IOException;
7 public final boolean readBoolean()throws IOException;
8 public final byte readByte()throws IOException;
9 public final int readUnsignedByte()throws IOException;
10 public final short readShort()throws IOException;
11 public final int readUnsignedShort()throws IOException;//读取16位短整型数
12 public final char readChar()throws IOException;
13 public final int readInt()throws IOException;
14 public final long readLong()throws IOException;
15 public final loat readFloat()throws IOException;
16 public final double readDouble()throws IOException;
17 public final String readLine()throws IOException;
18 public final String readUTF()throws IOException;//
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· winform 绘制太阳,地球,月球 运作规律
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)