Java tutorial
import java.io.FileInputStream; import java.io.IOException; import java.nio.channels.FileChannel; public class Main { public static void main(String[] args) throws IOException { int i = 0; FileInputStream fis = new FileInputStream("C://test.txt"); // read till the end of the file while ((i = fis.read()) != -1) { // get file channel FileChannel fc = fis.getChannel(); // get channel position long pos = fc.position(); char c = (char) i; System.out.println("No of bytes read: " + pos); System.out.println("Char read: " + c); } } }