What exactly does “Stream” and “Buffer” mean in Java I/O?

后端 未结 5 2049
北海茫月
北海茫月 2020-12-07 07:10

I just learned about input/output using BufferedReader.

I wanted to know what exactly are the meanings of the term Stream and Buffer<

5条回答
  •  误落风尘
    2020-12-07 07:27

    A Buffer is a portion in the memory that is used to store a stream of data from peripheral devices. Then from this buffer this stream of data is collected and stored in variables. A stream can be defined as a continuous flow of data.

    The very term “input/output” means nothing more than moving data in and out of buffers. Just keep this in your mind all the time. Processes perform I/O by requesting of the operating system that data to be drained from a buffer (write operation) or that a buffer be filled with data (read operation).
    Logical Diagram of how data moves

    In simple terms, imagine when you type data in a keyboard, the data moves through a pipe(the stream) to the buffer and then from buffer to the disk(write operation). Similarly when data moves from disk to buffer and from buffer to your console then it is read operation.

    You can read the links for better understanding. Hope it helps!.
    What is buffer in Java
    enter link description here

提交回复
热议问题