Java Buffer、Stream

 Buffer (Buffer) memory space is reserved in memory size specified for input / output (I / O) for temporary data storage, this part of the reserved memory space is called the buffer:
buffer is used with so two benefits:
1, to reduce the actual number of physical read and write
2, the buffer memory is assigned at the time of creation, this memory zone has been reused, can reduce the dynamic memory allocation and recovery times
cite a simple example, such as a 1w brick to have to move to point B
because there is no tool (buffer), we can only move one, then they would move 1w times (actual read and write times)
If a, B two great distance, then (IO performance consumption), then consumption will be a great performance
but if this time we have a big truck (buffer), one can transport 5000, then two times is enough
compared to the previous performance certainly greatly improved.
And generally in the actual process, we usually first file is read into memory, and then write from memory to other places
so that the input and output process, we can use caching to improve IO performance.
Therefore, buffer is important in the IO. In the old I / O class library (relative java.nio package) in BufferedInputStream, BufferedOutputStream, BufferedReader BufferedWriter in its implementation and use of both buffers. java.nio package disclosed Buffer API, so that a Java program can directly control and use of the buffer.

Reference: https://blog.csdn.net/z69183787/article/details/77102198

Java 8 API adds a new abstraction called stream Stream, allows you to process the data in a declarative way.
Stream uses a similar intuitive way to use SQL statements from the database query data to provide a higher level of abstraction for Java and set operations expression.
Stream API Java programmers can greatly improve the productivity of programmers to write efficient, clean, simple code.
This style element to be viewed as a collection of process flow stream in a pipeline transmission, and can be processed on the node conduit, such as filtering, sorting, polymerization.
Elementary stream in the pipeline intermediate operating treated (intermediate operation), and the final result obtained by the previous process is a final operation (terminal operation).

Reference: https://www.runoob.com/java/java8-streams.html

Guess you like

Origin blog.csdn.net/haoranhaoshi/article/details/94438988