易学笔记-0:Java语言总结/0.10 Java中接收输入的流表示(都是针对字节数组byte[ ]操作)

  • Java中接收输入的流表示
    1. 类示意图:
      1. 针对缓存的:
        1. ByteArrayInputStream
        2. StringBufferInputStream
      2. 针对文件的:FileInputStream
      3. 针对对象:ObjectInputStream
      4. 针对线程的:PipedInputStream
      5. 针对过滤器:FilterInputStream
        1. DataInputStream
        2. BufferedInputStream
    2. 超级基类:InputStream
      1. 读取一定字节到字节数组中:
        1. public int read(byte b[]) throws IOException
        2.  public int read(byte b[], int off, int len) throws IOException
      2. 跳过n个字符:public long skip(long n) throws IOException
      3. 可读取的字节数:public int available() throws IOException
      4. 关闭流:public void close() throws IOException
      5. 是否支持标记:public boolean markSupported()
      6. 标志:public synchronized void mark(int readlimit){}
    3. 字节数组输入流:ByteArrayInputStream
      1. 数据元素
        1. 字节数组:protected byte buf[];
        2. 当前位置:protected int pos;
        3. 当前标记,很多时候就是当前位置:protected int mark = 0;
        4. 字节数组元素数量:protected int count;
      2. 方法:
          1. 读取一定字节到字节数组中: public int read(byte b[]) throws IOException
          2.  读取一定字节到字节数组中: public int read(byte b[], int off, int len) throws IOException
          3. 跳过n个字符:public long skip(long n) throws IOException
          4. 可读取的字节数:public int available() throws IOException
          5. 关闭流:public void close() throws IOException
          6. 是否支持标记:public boolean markSupported()
          7. 标志:public synchronized void mark(int readlimit){}
    4. 文件输入流:FileInputStream
      1. 读取一定字节到字节数组中: public int read(byte b[]) throws IOException
        1. private native int readBytes(byte b[], int off, int len) throws IOException;
      2. public native long skip(long n) throws IOException;
      3. public native int available() throws IOException;
      4. 关闭流:public void close() throws IOException
        1. private native void close0() throws IOException;
      5.  
    5. 管道输入流:PipedInputStream
    6. 合并具体的输入流:SequenceInputStream
      1. 数据元素
        1. Enumeration e;
        2. InputStream in;
      2. public SequenceInputStream(Enumeration<? extends InputStream> e)
    7. 过滤输入流:FilterInputStream
      1. 数据成员
        1.  protected volatile InputStream in;
      2. 方法:通过通过in调用相关的方法,构造方法就是接受外面的输入对象,比如:ByteArrayInputStream、FileInputStream、PipedInputStream等,实际上调用的就是传进来的对象
    8. BufferedInputStream:缓冲区操作
    9. DataInputStream:适应各种数据类型的输入
      1. 超级基类:DataInput:接口用于从二进制流中读取字节,并根据所有 Java 基本类型数据进行重构
        1. 读取字节:void readFully(byte b[]) throws IOException;
        2. 读取字节:void readFully(byte b[], int off, int len) throws IOException;
        3. 跳过字节:int skipBytes(int n) throws IOException;
        4. 读取布尔类型:boolean readBoolean() throws IOException;
        5. 读取字节:byte readByte() throws IOException;
        6. 读取无符号字节:int readUnsignedByte() throws IOException;
        7. 读取短整型:short readShort() throws IOException;
        8. 读取整型:int readUnsignedShort() throws IOException;
        9. 读取字符:char readChar() throws IOException;
        10. 读取整型:int readInt() throws IOException;
        11. 读取长整型:long readLong() throws IOException;
        12. 读取浮点:float readFloat() throws IOException;
        13. 读取double:double readDouble() throws IOException;
        14. 读取一行:String readLine() throws IOException;
      2. DataInputStream:实现 DataInput 各个方法
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

易学笔记(qq:1776565180)

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值