The concept of stream in Java has been confusing for a long time. The following is an excerpt from the Internet:
At the beginning, I was confused about the concept of stream. After a long time, I finally understood it. After a long time, I was confused. Now I will make a summary and share it with you.
1. Java
In Java, the IO stream requires operating system resources, and the resources are freed after the use is complete.The IO stream can be divided into byte stream and character stream depending on the type of data being manipulated.The character
Java stream operations can be divided into byte streams and byte streams.
1. byte stream
All read Operations inherit from a common superclass java. io. InputStream class.
All write operations inherit from a common superclass java. io. OutputStream class.
Both
PrintStream (print output stream) and javaprintstream in JavaPrintStream in Java (print output stream)PrintStream is a print output stream that inherits from FilterOutputStream. PrintStream is used to decorate other output streams. It can be added to other output streams so that they can easily print various data value
The title of the sword refers to the offer face question 55
New Ket Network test address: https://www.nowcoder.com/questionTerminal/00de97733b8e4f97a3fb5c680ee10720The first character in a character stream that does not repeat the heat index: 26323 time limit: 1 seconds space limit: 32768K Please implement a function to find the first character in the character stream that appears only once. For example, w
. This is extremely important, it not only reduces the file space, and even if the code is not very sophisticated, there is no need to worry about an infinite loop (an example of an insensitive case where you can save objects in a recursive way without effectively auditing which objects have been saved, and then you may end up in a never-ending loop).
Unfortunately, the file format defined by the Java serialization mechanism appears to be fragile, a
Review an example of a stream containing null data. Java8examples.java
Package com.mkyong.java8;
Import java.util.List;
Import java.util.stream.Collectors;
Import Java.util.stream.Stream;
public class Java8examples {public
static void Main (string[] args) {
stream
Output
Java
python
node
null //
Solution (resolution)
To solve the above proble
Today, through the network resources to study how to use Java code to get the file, file stream or string encoding, now share the code with you:Package Com.ghj.packageoftool;import Info.monitorenter.cpdetector.io.asciidetector;import Info.monitorenter.cpdetector.io.byteordermarkdetector;import Info.monitorenter.cpdetector.io.codepagedetectorproxy;import Info.monitorenter.cpdetector.io.JChardetFacade; Import
input and output. They convert byte streams into the bridge converter of the dense stream and can specify the encoding/decoding method.Reader and writer (parent stream class, all parent stream types)1) Use of Java TechnologyUnicodeAnd provides a 16-bit stream to process cha
): Pipedreader, PipedWriter, PipedInputStream, PipedOutputStream
3.File file Stream
Read and write to files: FileReader, FileWriter, FileInputStream, FileOutputStream
4. Objectserialization
Object input, Output: ObjectInputStream, ObjectOutputStream
5.DataConversion Data Flow
Read and write by basic data type (processed data is the basic type of Java (such as Boolean, Byte, Integer, and floating-point numbe
Http://www.cnblogs.com/qqzy168/p/3670915.html——————————————————————————————————————————————————————Problem:(1) The IO stream of Java uses the adornment mode, when closing the outermost stream, it automatically calls the close () side of the wrapped stream?(2) If the flow is closed sequentially, is it from the inner lam
8. Character Stream Writer/reader the characters in Java are in the Unicode standard, one character is 16 bits, that is, one character is represented by two bytes. To do this, a stream that handles characters is introduced in Java. 1. Reader abstract class Abstract class for reading
contents of the file Ep10_1.txt)It is important to note that Java treats a Chinese or English letter as a character, a carriage return or a newline as two characters.Reading files using the BufferedReader classThe BufferedReader class is used to read the data in the buffer. You must create a FileReader class object when you use it, and then create an object of the BufferedReader class with that object as a parameter. The BufferedReader class has two
stream.OutputStreamThis abstract class is a superclass of all classes that represent the output byte stream. The output stream accepts output bytes and sends those bytes to a sink. Applications that need to define outputstream subclasses must always provide at least one way to write an output byte.void Close ()Closes this output stream and frees all system resou
outputstream to writer Transformation Bridge, its subclass filewriter is actually a concrete class to implement this function; * */public class IO {public static void Main (string[] args) throws IOException {//character stream string path = "Data/data"; BufferedReader br = new BufferedReader (new InputStreamReader (New FileInputStream (path), "Utf-8")); String line = "", while (line = Br.readline ())! = null) {System.out.println (line);} Br.close ();
, which can be used to encode and measure most files. Therefore, generally with this detector can meet the requirements of most projects, if you are not at ease, you can * add a few more detectors, such as the following asciidetector, Unicodedetector and so on. */Detector.add (Jchardetfacade.getinstance ());//used to Antlr.jar, Chardet.jar//Asciidetector for ASCII code determination//Detector.add (Asciidetector.getinstance ()); //Unicodedetector for the determination of Unicode family co
abstract class is a super class that represents all the classes of the output byte stream. The output stream accepts the output bytes and sends them to a receiver. Applications that need to define the outputstream subclass must always provide at least one method that can write one output byte.
Void close ()Close the output stream and release all system resources
The IO stream in Java is used to process the data transfer from the device to the device before it is streamed in Java. Streams fall into two categories: byte stream and character stream.BYTE stream: Inputstream,outputsteam. (The data in the computer is stored in bytes, and
-----------android training ,Java training , Java Learning Technology blog, look forward to communicating with you! ------------First: Dark Horse programmer _ Bi Xiangdong _java Basic Video tutorial 20th day -01-io Stream (file overview) One, the file class understanding:
Used to encapsulate a file or folder as an object.
Easy to manipulate files
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.