This page contains an archived post to the Java Answers Forum made prior to February 25, 2002.
If you wish to participate in discussions, please visit the new
bytes & integers in streams
Posted by Feroz on August 08, 2001 at 1:30 PM
ok, let me explain.
if u use the read() method in the FileInputStream to read Data, it reads 1 byte at a time. it does not matter how big the integer is, or whatever other data-type. the method will read in 8-bit chunks, until all the data has been read... and likewise it will write in 8 bit-chunks until all the data in the stream has been written - this means that for something that is 32-bits long, it will take 4 reads(). it would be helpful to think what goes on at the machine code level. i hope this helps.
UCT Computer Science and Electrical Engineering Dept,