Java tutorial
import java.io.FileReader; import java.io.IOException; import java.io.LineNumberReader; public class Main { 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); } lnr.close(); } }