If the class is in the InputStream/OutputStream category, it
is a stream for reading and writing bytes??”raw data, 8 bits at a time.
Students are sometimes confused thinking about the difference between character data and bytes. Are not
bytes used to encode characters? Yes they are. In fact, we could get along with just the InputStream/
OutputStream classes, and let programs be responsible for making sense of the data by converting the data to
characters when that was appropriate.
However, often data sources consist of character data, and it is very convenient to have I/O classes for
that common situation. If the information exists in the form of characters, a Reader/Writer will interpret
the information correctly and return a set of characters to the program. This saves the programmer having to
write a tedious conversion that would otherwise be necessary frequently.
If the information exists in some other form than characters, such as binary numbers in integer or floatingpoint
format, as in an image file, then it will not make sense to interpret the bit patterns as characters. In that
case, the programmer should use the InputStream/OutputStream classes, which will simply transfer the
bytes. Then the program will be responsible for interpreting the bytes correctly.
Pages:
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240