List of usage examples for java.io LineNumberReader read
@SuppressWarnings("fallthrough") public int read(char cbuf[], int off, int len) throws IOException
From source file:Main.java
public static void main(String[] args) throws IOException { char[] cbuf = new char[5]; // create new reader FileReader fr = new FileReader("C:/test.txt"); LineNumberReader lnr = new LineNumberReader(fr); // read characters into the buffer int i = lnr.read(cbuf, 2, 3); System.out.println("Number of char read: " + i); // for each character in the buffer for (char c : cbuf) { // if char is empty if ((int) c == 0) c = '-'; // prints char System.out.print(c);/*from w ww .j a va 2s. c o m*/ } lnr.close(); }