. Print ((char) b);//"char (b)" Converts Chinese and English letters using numbers to character input num++;27}28 In.close ();//Close input stream System.out.println (); System.out.println ("Read all" + num + "bytes"); 31 } catch (IOException E1) {System.out.println ("file read error! "); 33}34}35}Example: Using a fileoutputstream stream to write data to a file 1 package cn.galc.test; 2
);//"char (b)" Converts Chinese and English letters using numbers to character input num++;27}28 In.close ();//Close input stream System.out.println (); System.out.println ("Read all" + num + "bytes"); 31 } catch (IOException E1) {System.out.println ("file read error! "); 33}34}35}Example: Using a fileoutputstream stream to write data to a file 1 package cn.galc.test; 2 3 Import java.io.*; 4 5 publi
PackageCom.swift.baseKnowledge;ImportJava.io.File;ImportJava.io.FileInputStream;ImportJava.io.FileOutputStream;Importjava.io.IOException;ImportJava.io.InputStreamReader;ImportJava.io.ObjectInputStream;ImportJava.io.OutputStreamWriter;ImportJava.io.PrintStream;ImportJava.io.PrintWriter;/*existing string: "I love Java". Save the string to the A.txt file in the root directory of the current project. Requirement: Save with UTF8 encoding. Procedure Descrip
value of public static void main (String [] args) in a linked List {List
K = new ArrayList
(); K. add (1); k. add (2); k. add (3); k. add (8); k. add (11); k. add (20); k. add (50); Optional
Max = k. parallelStream (). max (a, B)-> {return a-B;}); System. out. println (max );}
It's easy. Change k. stream () to k. parallelStream ()
This is simp
Java advanced ------ IO stream
Concept and basic classification of stream: Concept of stream:
Stream is a very visual concept. When the program needs to read data, it will open a stream to the data source, which can be a file,
-FileInputStream FileInputStream =Newfileinputstream (file); - //3. Create a buffer - //3k in byte[] B =New byte[1024];//generally write 1024 times times the larger the buffer is theoretically set, the higher the efficiency of reading - //4. Reading data to intCount = 0; + while(count = Fileinputstream.read (b))!=-1){ - theSystem.out.println (NewString (b,0, Count)); * } $ //5. Close ResourcesPanax N
OverviewIO streams are used to process data transfer between devicesHow Java operates on data by streamingThe objects that Java uses to manipulate the flow are in the IO packageStream-by-operation data is divided into: byte stream and character streamFlow is divided into: input stream and output
The IO stream of Java is divided into character stream (Reader,writer) and Byte stream (Inputstream,outputstream), and the byte stream is the name stream that reads the contents of the file into the array of bytes and then outputs
Fileoutstream, fileinputstream, filereader, and fileewiter are often used to learn Java Io streams.
Generally, the byte stream is used to read Chinese characters, because a Chinese character is regarded as a character in the byte stream.
A stream is an ordered byte sequence that can be used as an input source or an o
character stream to wrap the character stream, the surface is a stream of characters, in fact, the bottom is the byte stream (standard output stream)7 //OutputStreamWriter OSW = new OutputStreamWriter (OS);8
.
Console input and output:Version after JDK 5 We can also use the Java Scanner class to get input from the console.Read and write files:FileInputStreamMethod 1: You can use the file name of the string type to create an input stream object to read the fileNew FileInputStream ("C:/java/hello");Method 2: You can also use a file object to create an input
Stream is a newly added class of Java 8 that complements the collection class.The stream represents the data stream, and the number of data elements in the stream can be limited or infinite.The difference between
Byte Stream and character streamByte stream can handle all types of data (pictures, videos, etc.), the corresponding class in Java is "stream" End 1 bytes = 8 bits binary = The specific storage space character stream can only hand
character encoding;
6. Pipeline Input class: PipedInputStream classThe pipeline stream reads data from a management output flow. Typically one thread writes data to the management output stream, and another thread reads data from the management input stream, and two threads can communicate with the pipeline.7. Reader and writer OverviewThe InputStream and O
Java core programming-byte stream of IO stream (2), javaio
1. byte stream
A 1.1-byte stream is a stream that operates byte. Byte streams can operate on any data, such as media data, music, movies, and images. Of course, they can a
1. Demand: e:\\ brother has a wife. mp4 copied to Copy.mp4 in the current project directorybyte stream Four ways of copying files :• Basic byte stream read and write one bytes at a time• Basic byte stream reads and writes a single array of bytes at a time• High-efficiency byte stream read and write one bytes at a time•
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.