zoukankan      html  css  js  c++  java
  • InputStream中mark方法使用

    在调用mark的地方做上标记,参数readlimit说明在读取readlimit个字符后书签做废(6.0好像没有失效 ,仍然可以标记位置),使用reset后回到标记的位置.
    import java.io.*;
    public class Test{
    public static void main(String[] args){
    try{
    BufferedInputStream bis=new BufferedInputStream(new FileInputStream("d:/a.txt"));
    System.out.println((char)bis.read());
    System.out.println((char)bis.read());
    bis.mark(6);//6.0中不管读多少mark仍然有效
    System.out.println((char)bis.read());
    System.out.println((char)bis.read());
    bis.reset();
    System.out.println((char)bis.read());
    System.out.println((char)bis.read());
    }catch(IOException e){
     e.printStackTrace();
    }
    }
    }

    6.0下测试结果为:
    a
    b
    c
    d
    c
    d

  • 相关阅读:
    centos 7 和 centoa 8的区别
    centos7制作U盘启动盘
    juypyter notebook安装
    Centos6安装MariaDB
    提job
    report a bug and update
    runtest提交job
    bug
    ps常用选项
    每日一句
  • 原文地址:https://www.cnblogs.com/pangpanghuan/p/6404442.html
Copyright © 2011-2022 走看看