package class9_1_FileChannelAndByteBuffer; import java.io.*; import java.nio.ByteBuffer; /** * Like Reader, only using a FileChannel. * * Now we can read a whole buffer at a time... * * We still don't handle all the problems that could occur. */ public class FileChannelReader { public static void main(String[] args) { try(FileInputStream is = new FileInputStream("binary.bin")) { int firstByteAsInt = is.read(); ByteBuffer buffer = ByteBuffer.allocate(firstByteAsInt); is.getChannel().read(buffer); buffer.rewind(); for(int i = 0; i