import java.io.*; import java.nio.*; import java.io.FileInputStream; import java.nio.ByteBuffer; import java.nio.channels.FileChannel; public class GetIndexValue { public static void main(String[] args) throws IOException { int index = 4; FileInputStream aFile = new FileInputStream("testfile1.txt"); FileInputStream bFile = new FileInputStream("testfile2.txt"); FileChannel inChannel = aFile.getChannel(); FileChannel inChannelb = bFile.getChannel(); ByteBuffer buf = ByteBuffer.allocate(256); int bytesRead = inChannel.read(buf); buf.flip(); System.out.println("Value in first buffer at index " + index + " : " + (char) buf.get(index)); buf.clear(); int bytesReadb = inChannelb.read(buf); buf.flip(); System.out.println("Value in second buffer at index " + index + " : " + (char) buf.get(index)); aFile.close(); } }