Working with Streams 595
17
problem, streams provide “buffering.” When buffering is used, data is written into the
stream, but is not written back out to the disk immediately. Instead, the stream’s buffer
fills and fills, and when it is full, it writes to the disk all at once.
FIGURE17.1 Encapsulation through streams.
Stream Monitor
Keyboard
Disk Disk
data
data
data
data
Although data is technically a plural noun, we treat it as singular, as do
nearly all native speakers of English.
NOTE
Picture water trickling into the top of a tank and the tank filling and filling, but no water
running out of the bottom. Figure 17.2 illustrates this idea.
FIGURE17.2
Filling the buffer.