-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
1. What is a streamThe stream in Java is an abstraction of a sequence of bytes, and we can imagine a water pipe, except that it is no longer the water that flows in the pipe, but the sequence of bytes. Like currents, streams in Java also have a "flow direction," where an object that is typically read into a sequence of bytes is called an input
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
one, byte output streamOutputStream Abstract classThis abstract class is a superclass of all classes that represent the output byte stream. The data of operation is byte, and the basic common function method of output byte stream is defined.
BYTE: This stream only operates 1 bytes in the file at a time
Stream
IO stream in java and javaIO stream
Stream: java stream is a class developed by Sun for file operations and data transmission, but it is called a stream. all opened streams must be clos
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
.JavaInputStream is the ancestor of all byte input streams, and OutputStream is the ancestor of all byte output streams.Character Stream of 2.JavaReader is the ancestor of all read string input streams, while writer is the ancestor of all output strings.Inputstream,outputstream,reader,writer are abstract classes. So you can't just newByte stream is the most basic, all inputstream and OutputStream subclasses
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 //bufferedwriter bw = new Buffered
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
Foreach statements Use Summary foreach statements are one of the new features of Java 5. In terms of traversing arrays and collections, foreach provides great convenience for developers. The foreach statement is a special simplified version of the for statement, but the
1. What is a streamThe stream in Java is an abstraction of a sequence of bytes, and we can imagine a water pipe, except that it is no longer the water that flows in the pipe, but the sequence of bytes. Like currents, streams in Java also have a "flow direction," where an object that is typically read into a sequence of bytes is called an input
1. What is a streamThe stream in Java is an abstraction of a sequence of bytes, and we can imagine a water pipe, except that it is no longer the water that flows in the pipe, but the sequence of bytes. Like currents, streams in Java also have a "flow direction," where an object that is typically read into a sequence of bytes is called an input
Summary of Use of foreach statementThe foreach statement is one of the new features of Java5, and foreach provides a great convenience for developers in traversing arrays and collections. The foreach statement is a special, simplified version of the for statement, but the foreach
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
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 handle the data of plain text, the corresponding
The last time we used a byte stream, there was a character stream, the last time we talked about how to tell which stream to use, and if Notepad could read it, use a character stream, or use a byte stream. Using a character stream
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.