Example usage for java.io LineNumberInputStream mark

List of usage examples for java.io LineNumberInputStream mark

Introduction

In this page you can find the example usage for java.io LineNumberInputStream mark.

Prototype

public void mark(int readlimit) 

Source Link

Document

Marks the current position in this input stream.

Usage

From source file:Main.java

public static void main(String[] args) throws IOException {
    FileInputStream fis = new FileInputStream("C:/test.txt");
    LineNumberInputStream lnis = new LineNumberInputStream(fis);

    System.out.println((char) lnis.read());
    System.out.println((char) lnis.read());

    lnis.mark(0);
    System.out.println("mark() invoked");
    System.out.println((char) lnis.read());
    System.out.println((char) lnis.read());

    if (lnis.markSupported()) {
        lnis.reset();//ww w.  ja v a 2 s  . c om
        System.out.println("reset() invoked");
        System.out.println((char) lnis.read());
        System.out.println((char) lnis.read());
    }

}

From source file:Main.java

public static void main(String[] args) throws IOException {

    FileInputStream fis = new FileInputStream("C:/test.txt");
    LineNumberInputStream lnis = new LineNumberInputStream(fis);

    System.out.println((char) lnis.read());
    System.out.println((char) lnis.read());

    lnis.mark(0);
    System.out.println("mark() invoked");
    System.out.println((char) lnis.read());
    System.out.println((char) lnis.read());

    if (lnis.markSupported()) {
        lnis.reset();//from   w  ww  .j a va  2  s  .c  o  m
        System.out.println("reset() invoked");
        System.out.println((char) lnis.read());
        System.out.println((char) lnis.read());
    }

}