A BufferedInputStream adds functionality to another input stream-namely, the ability to buffer the input and to support the and reset methods. When the BufferedInputStream is created, an internal buffer array is created. As bytes from the stream are read or skipped, the internal buffer is refilled as necessary from the contained input stream, many bytes at a time. The operation remembers a point in the input stream and the reset operation causes all the bytes read since the most recent operation to be reread before new bytes are taken from the contained input stream.
BufferedInputStream(InputStream in)
Creates a BufferedInputStream and saves its argument, the input stream in, for later use.
BufferedInputStream(InputStream in, int size)
Creates a BufferedInputStream with the specified buffer size, and saves its argument, the input stream in, for later use.
Method Summary
int available()
Returns the number of bytes that can be read from this input stream without blocking.
void close()
Closes this input stream and releases any system resources associated with the stream.
void (int readlimit)
See the general contract of the method of InputStream.
boolean Supported()
Tests if this input stream supports the and reset methods.
int read()
See the general contract of the read method of InputStream.
int read(byte[] b, int off, int len)
Reads bytes from this byte-input stream into the specified byte array, starting at the given offset.
void reset()
See the general contract of the reset method of InputStream.
long skip(long n)
See the general contract of the skip method of InputStream.
看下DOC不就什么都明白了吗
BufferedInputStream(InputStream in)
Creates a BufferedInputStream and saves its argument, the input stream in, for later use.
BufferedInputStream(InputStream in, int size)
Creates a BufferedInputStream with the specified buffer size, and saves its argument, the input stream in, for later use.
Method Summary
int available()
Returns the number of bytes that can be read from this input stream without blocking.
void close()
Closes this input stream and releases any system resources associated with the stream.
void (int readlimit)
See the general contract of the method of InputStream.
boolean Supported()
Tests if this input stream supports the and reset methods.
int read()
See the general contract of the read method of InputStream.
int read(byte[] b, int off, int len)
Reads bytes from this byte-input stream into the specified byte array, starting at the given offset.
void reset()
See the general contract of the reset method of InputStream.
long skip(long n)
See the general contract of the skip method of InputStream.
看下DOC不就什么都明白了吗
解决方案 »
- 关于聊天程序怎么实现两个客户端的通行啊 请高手指教
- 我有java数据结构与算法的问题~高手请帮忙看看~~第一次发帖,到处询问~不好意思。
- 最基础问题!
- 哈哈,需要短信网关IP地址及其源代码的快来顶一下。
- 求解答~,jtable怎么实现不可鼠标选中
- 问一个servlet和applet通信地问题,请各位来看一下。 (在线等)
- 关于在jb7上的程序运行问题?
- 如何定位jb中的光标,我的光标总和字符的位置不相符。
- 哪伟大虾有将视频、音频封装成ejb构件的代码?
- 如何使一个JDialog弹出时,上面的组件都没有焦点
- jinternalframe 怎么去掉标题栏及最大最小化和关闭按钮?
- 请问Microsoft SDK for Java 4.0在那里有的下载阿?
BufferedInputStream(InputStream in, int size)
缓冲输入流(BufferedInputStream):顾名思义,是在缓冲区取数据的输入流(InputStream)。输入流都是在硬盘数据源去数据的。要从缓冲区取数据,那缓冲区里面要有数据的,对吧?谁写进去呢?当然是输入流(InputStream)了,所以要建立缓冲输入流(BufferedInputStream),必须指定一个输入流。 FileInputStream instr=new FileInputStream("girlsjj.dat");
FileInputStream是InputStream的子类,表示从一个硬盘上的文件girlsjj.dat中取数据。
于是 BufferedInputStream buff=new BufferedInputStream(instr);
然后,你就可以使用buff来读取数据了。
buff.read(); //读的具体细节看看书。以上表示girlsjj.dat文件中的数据先写入内存中的缓冲区,然后从缓冲区里读到程序中。 同时你还可以指定缓冲区的大小:BufferedInputStream(InputStream,int)
//大小为int的缓冲区。