Java tutorial
import java.io.FileInputStream; import java.io.IOException; import java.io.LineNumberInputStream; public class Main { public static void main(String[] args) throws IOException { byte[] buf = new byte[5]; char c; 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); } } }