Java IO Tutorial - Java LineNumberInputStream .setLineNumber (int lineNumber)








Syntax

LineNumberInputStream.setLineNumber(int lineNumber) has the following syntax.

public void setLineNumber(int lineNumber)

Example

In the following code shows how to use LineNumberInputStream.setLineNumber(int lineNumber) method.

/*www. ja  v  a  2s.c o m*/


import java.io.FileInputStream;
import java.io.IOException;
import java.io.LineNumberInputStream;

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

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

    lnis.setLineNumber(100);

    int i = lnis.getLineNumber();

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

  }
}