byte buffer stream
byte buffered stream:
BufferedOutputStream: byte buffered output stream.
BufferedInputStream: byte buffered input stream.
Construction method:
BufferedOutputStream(OutputStream out)
BufferedInputStream(InputStream in)
The constructor expects a stream of bytes, not a specific file or path.
The byte buffer stream only provides a buffer, and the real read and write data must rely on the basic byte stream object for operation.
copy using byte buffer
private static void demo05() throws IOException {
BufferedInputStream bis = new BufferedInputStream(new FileInputStream("E:\\Steve.pdf"));
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("Steve.pdf"));
byte[] bytes = new byte[1024];
int i = 0;
while ((i = bis.read(bytes)) != -1) {
bos.write(bytes, 0, i);
}
bos.close();
bis.close();
}
summary:
The byte buffer stream is equivalent to a truck, and a byte stream needs to be passed in, that is, the driver to operate.
Improve efficiency through byte buffering.