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

  • 相关阅读:
    JQuery性能优化
    分页控件X.PagedList.Mvc
    《转》sql 、linq、lambda 查询语句的区别
    Linq的连表查询
    MVC页面直接F5出错
    详解集合
    Json的序列化与反序列化
    《转》dbcontext函数
    《转》jquery中的$.ajax的success与error
    cocos creator基础-(二十七)httpclient Get POST
  • 原文地址:https://www.cnblogs.com/ywqtro/p/11407381.html
Copyright © 2011-2022 走看看