Example usage for java.io LineNumberInputStream getLineNumber

List of usage examples for java.io LineNumberInputStream getLineNumber

Introduction

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

Prototype

public int getLineNumber() 

Source Link

Document

Returns the current line number.

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);

    lnis.setLineNumber(100);/*  w w w .  j  av a 2 s . c  o  m*/

    int i = lnis.getLineNumber();

    System.out.print("Line number: " + i);

}

From source file:Main.java

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

    int i;/*from  w  ww  . ja  v  a  2s . c  o m*/
    FileInputStream fis = new FileInputStream("C:/test.txt");
    LineNumberInputStream lnis = new LineNumberInputStream(fis);

    while ((i = lnis.read()) != -1) {
        char c = (char) i;

        if (i != 10) {
            System.out.println("Character read: " + c);

            int j = lnis.getLineNumber();
            System.out.println(" at line: " + j);
        }
    }

}