Example usage for java.io LineNumberInputStream read

List of usage examples for java.io LineNumberInputStream read

Introduction

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

Prototype

public int read(byte b[], int off, int len) throws IOException 

Source Link

Document

Reads up to len bytes of data from this input stream into an array of bytes.

Usage

From source file:Main.java

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

    byte[] buf = new byte[5];

    char c;//from  w  ww .  jav  a  2s  .c om

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

    int i = lnis.read(buf, 2, 3);
    System.out.println("The number of char read: " + i);

    for (byte b : buf) {
        if (b == 0)
            c = '-';
        else
            c = (char) b;

        System.out.print(c);
    }

}