zoukankan      html  css  js  c++  java
  • 学习Java第八周

    1.流的分类

    1、字节流:Stream

    2、字符流: Writer,Reader

    输入流 :InputStream ,Reader

    输出流 :OuputStream,Writer

    字节流重要还是字符流重要:字节流:字节流类为处理字节式输入/输出提供了丰富的环境。

    不仅仅可以读二进制,也可以读文本。 字符流:只能读文本。

    流的分类:

    字节输入流:InputStream

    字节输出流:OuputStream

    字符输入流:Reader

    字符输出流:Writer

    2.InputStream流

    1、public abstract class InputStream 见到抽象,不能用它创建对象。

    2、方法:

    public abstract int read() throws IOException

    public int read(byte b[]) throws IOException 

    public int read(byte b[], int off, int len) throws IOException 

    public int available() throws IOException //返回有效字节数。

    available方法的作用:取得有效字节数。不调用read()方法的时候,文件指针指向第一个字符前,后面有文件大小个字符没有读。

    public void close() throws IOException 关闭。

    3.OutputStream字节输出流

    1、public abstract class OutputStream 

    2、方法:

    public abstract void write(int b) throws IOException

    public void write(byte b[], int off, int len) throws IOException 

    public void flush() throws IOException 清理缓存。

    public void close() throws IOException

    4.字符输入流Reader

    1、public abstract class Reader

    2、方法:

     public abstract int read() throws IOException

  • 相关阅读:
    linux内存-swap
    linux内存-buffer和cache
    Linux内存-内存管理机制oom_killer
    HTTPS(二)证书合法性校验
    HTTPS(一)基础及连接建立
    docker镜像(一)overlayfs
    DNS(三)全局流量调度
    建造者模式(Builder Pattern)
    抽象工厂模式(Abstract Factory)
    工厂方法模式(Factory Method Pattern)
  • 原文地址:https://www.cnblogs.com/ywqtro/p/11407381.html
Copyright © 2011-2022 走看看