The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
April 2001



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 Artima Forums.


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.

Feroz Patel
UCT Computer Science and Electrical Engineering Dept,
South Africa


Sponsored Links

Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us