Java tutorial
import java.io.BufferedInputStream; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; public class Main { public static void main(String[] args) throws Exception { InputStream inStream = new FileInputStream("c:/test.txt"); BufferedInputStream bis = new BufferedInputStream(inStream); // read until a single byte is available while (bis.available() > 0) { // get the number of bytes available Integer nBytes = bis.available(); System.out.println("Available bytes = " + nBytes); // read next available character char ch = (char) bis.read(); // print the read character. System.out.println("The character read = " + ch); } } }