Buffered Streams

http://java.sun.com/docs/books/tutorial/essential/io/buffers.html

Most of the examples we've seen so far use unbuffered I/O. This means each read or write request is handled directly by the underlying OS. This can make a program much less efficient, since each such request often triggers disk access, network activity, or some other operation that is relatively expensive.

前面的代码都是未缓冲IO实现的,这就表示每次操作都要触发磁盘访问或者网络,这些操作都很昂贵。

To reduce this kind of overhead, the Java platform implements buffered I/O streams. Buffered input streams read data from a memory area known as a buffer; the native input API is called only when the buffer is empty. Similarly, buffered output streams write data to a buffer, and the native output API is called only when the buffer is full.

为了减小开支,java实现了带缓冲的流。
输入流直接从内存的一块区域得到,也就是所说的buffer
input api只在缓冲区空了以后才被调用。类似的,输出直接写入缓冲区,只有当满的时候才调用output api。

unbuffered 未缓冲的流只需要包装一下就可以成为一个带缓冲的流了。

There are four buffered stream classes used to wrap unbuffered streams: BufferedInputStream and BufferedOutputStream create buffered byte streams, while BufferedReader and BufferedWriter create buffered character streams.

Flushing Buffered Streams

It often makes sense to write out a buffer at critical points, without waiting for it to fill. This is known as flushing the buffer.

写入缓冲临界点,还未满。所谓的冲洗缓冲区
Some buffered output classes support autoflush, specified by an optional constructor argument. When autoflush is enabled, certain key events cause the buffer to be flushed. For example, an autoflush PrintWriter object flushes the buffer on every invocation of println or format. See Formatting for more on these methods.
有些类支持自动冲洗缓存。或者在构造参数里可以指定。当自动冲洗开启,某些事件会触发缓冲被冲洗。例如 PrintWriter 调用 println 或 format 。

你可能感兴趣的:(html,OS,Access,sun)