What is a stream

I am writing the code for the first time in new employee training at work. I think streams are a very basic thing, I can't help but find out what I didn't understand.

Stream is "flow" in Japanese. I feel that the word "data flow" often appears in sentences that describe streams. But when I say "flow", it doesn't come to my mind.

Definition

In the field of programming, it often means an abstract object or data type that handles data input / output in general. It is an abstraction that allows you to handle some object (memory area, file, network, etc.) in which data enters and exits in the program, and you can connect, disconnect, write, and read with simple operations.

Source e-words(http://e-words.jp/w/%E3%82%B9%E3%83%88%E3%83%AA%E3%83%BC%E3%83%A0.html)

Does it mean something like "a program that can handle the area where data goes in and out"?

So how do you handle streams in Java?

All Java I / O features are designed around the concept of "streams", which represent the flow of characters and byte sequences. In Java, streams are a standardized mechanism for reading and writing data, and all objects in Java that represent variable data sources provide methods for reading and writing data as streams.

Source builder(https://builder.japan.zdnet.com/java/20363416/)

Oh, when all I / O processing is done in streams in Java ...

Classes that handle stream-oriented I / O are often included in the java.io package. At the heart of this package are two abstract classes, the InputStream class and the OutputStream class. All other stream-oriented classes are defined as extensions of these classes.

Source Same as above

I see. As illustrated on the original site, The FileReader class also inherits the InputStream class. So, if you use it, you will be using a stream.

java.io.FileReader fileReader = new java.io.FileReader("/home/me/myfile.txt");

int aChar = 0;
while ((aChar = fileReader.read()) >= 0){
    System.out.println((char)aChar);
}

So what's the difference between using a stream and not using it? The question arises, but I will come back to that later. .. ..

Recommended Posts

What is a stream
What is a Servlet?
What is a wrapper class?
What is a Ruby module?
What is a floating point?
What is a meaningful comment?
What is a jar file?
What is a Java collection?
What is a lambda expression?
What is a fa⁉ enum?
What is a snippet in programming?
What is a column Boolean type?
What is a reference type variable?
What is a lambda expression (Java)
[Swift] What is "inheriting a class"?
What is a Ruby 2D array?
What is Cubby
What is Docker?
What is null? ]
What is java
What is Keycloak
What is maven?
What is Jackson?
What is Docker
What is self
What is Jenkins
What is ArgumentMatcher?
What is IM-Juggling?
What is params
What is SLF4J?
What is Facade? ??
What is Java <>?
What is Gradle?
What is POJO
What is Java
What is centOS
What is RubyGem?
What is programming?
What is before_action?
What is Docker
What is Byte?
What is Tomcat
What is a class in Java language (3 /?)
What is a terminal? -Absolute path & relative path-
What is a Spring Boot .original file?
[For programming beginners] What is a method?
What is a class in Java language (1 /?)
What is a class in Java language (2 /?)
[Rails] What is a dot (.) Or a colon (:)?
What is a request scope? Image commentary
What is Maven Assembly?
What is `docker-compose up`?
What is vue cli
Introduction to Recursive Functions: What is a Recursive Function?
What is an interface?
What is Ruby's self?
What is Ruby's attr_accessor?
What is Java Encapsulation?
What is permission denied?
What is instance control?
What is an initializer?