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 。
分享到:
相关推荐
Python参考手册,官方正式版参考手册,chm版。以下摘取部分内容:Navigation index modules | next | Python » 3.6.5 Documentation » Python Documentation contents What’s New in Python ...
modify brpc library doubly_buffered_data class. test performancy. 100000000 test Get total : 16557607309 ns, avg 165 ns Set total : 21681584661 ns, avg 216 ns
TMS320VC5501/5502/5503/5507/5509/5510 DSP Multichannel Buffered Serial Port (McBSP) Reference Guide
Fully-Buffered DIMM Memory Architectures: Understanding Mechanisms, Overheads and Scaling
TMS320F28x Multichannel Buffered Serial Port (McBSP) Referen
JEDEC JESD82-28A:2008 Fully Buffered DIMM Design for Test,Design for Validation (DFx) - 完整英文电子版(102页).zip
var InterpolationBuffer = require('buffered-interpolation'); let interpolationBuffer = new InterpolationBuffer(); 收到联网数据时: interpolationBuffer.setPosition(new THREE.Vector3(data.x, data.y, ...
GLib testing framework examples and tests.
Streaming graph analysis extracts timely insights from evolving graphs, and has... Nevertheless, we find that for widely used monotonic graph algorithms, the buffered updates can be effectively preproces
JEDEC JESD82-28A:2008 Fully Buffered DIMM Design for Test,Design for Validation (DFx) - 完整英文电子版(102页).pdf
使用缓冲区方式(DO_BUFFERED_IO)进行用户模式和内核模式地址的数据交互。包括驱动程序和用户模式的测试程序。用DDK编译驱动,VS2008编译测试程序。
用法ember install ember-buffered-proxy import BufferedProxy from 'ember-buffered-proxy/proxy' ;let content = { firstName : 'stefan'} ;let buffer = BufferedProxy . create ( { content : content} ) ;...
通常在绘图的时候,你都不会直接在BeginPaint或CDC中使用HDC,如果你这样做了,那么当你绘制很多东西的时候,就有可能造成图像的闪烁。双缓冲就是用在这里实现图像的平滑的更新的。 有很多实现的方法,一种是在内存...
该代码主要实现了ATM系统的主要功能,包括账号的注册和登录,个人的余额查询、存取款、转账、登录记录查询以及操作记录查询,用户的数据用文本文件存储,所以再一次使用的时候不会被清除数据。
TMS 手册
用法{{ model.name }}{{ #buffered-proxy content = model as | content apply discard hasChanges | }} {{ content.name }} (Has changes: {{ hasChanges }} ) {{ input value = content.name }} < button {{ ...
Hydroxyl-free buffered dielectric for graphene field-effect transistors
var BufferedSink = require ( 'buffered-sink' ) ; var jsonFileSink = new BufferedSink ( { maxSize : 5 , writeItems : function ( items , cb ) { var existing ; try { existing = JSON . parse ( fs . ...
Javascript 缓冲撤消管理器这个库提供了一个简单的撤消管理器和更新缓冲,以避免在内容快速变化的场景中撤消对用户来说变得数据密集或繁琐。要求目前 BufferedUndoManager 需要 jQuery 和 Underscore。...
缓冲加密安全地逐块加密大型数据文件。 该软件包在GCM模式下使用AES加密和解密文件流。 它依赖于加密库来执行加密。... import osfrom buffered_encryption . aesgcm import EncryptionIterator , Decrypti