Tips"Effective Java, third Edition" an English version has been published, the second edition of this book presumably many people have read, known as one of the four major Java books, but the second edition of 2009 published, to now nearly 8 years, but with Java 6, 7, 8, and
. The BufferedReader class belongs to the filter stream, often with other flows such as filereader as their input or output. It is constructed in the following ways:BufferedReader (Reader in);BufferedReader (Reader in, int bufSize);For example:FileReader fr=new FileReader ("D:\1.txt");BufferedReader buf = new BufferedReader (FR);BufferedReader provides a readerline () method to read each line of text.5, Buf
Original link: http://www.concretepage.com/java/jdk-8/java-8-stream-sorted-exampleForeign to Java8 a series of summary of Good, translation come to shareThis article will explain the Java 8
Memory Stream (Array stream):The data is temporarily present in the array and will be retrieved from the array later.1. Byte memory stream: Bytearrayinputstream/bytearrayoutputstream2. Character Memory stream: Chararrayinputstream/chararrayoutputstream3. String stream: Strin
-matched. 4. transient keyword transientwhen an object of a class needs to be serialized, some attributes do not need to be serialized, and attributes that do not need to be serialized can be decorated with the keyword transient . This property is not serialized when serialized, as long as the transient is modified. Static adornments are not serialized at the same time, because serialization is the persistent storage of object data, while static data belonging to the class load is not serializ
BYTE buffer streamWhy use wrapper flows, which are used to improve the performance of read and write operations. public class Packing_flowdemo {public static void main (string[] args) throws Exception {File File = new file ("File/packing _flow.txt ");//The notation of the wrapper stream, the buffer memory size. 1024*8=8192 (byte)//bufferedoutputstream packing = new Bufferedoutputstream (new FileOutputStrea
Label:1. Random Access Stream Randomaccessfile The Randomaccessfile class does not belong to a stream and is a subclass of the object class. But it incorporates the functions of InputStream and OutputStream. Supports read and write to random access files. Randomaccessfile Method of Construction:
Construction Method Summary
RandomAccessFile(Filefile, Stringmode)Creates a rando
("Bbb.txt"); if there is no bbb.txt, it creates an int b;14 while ( (B=fis.read ())!=-1) { fos.write (b); }17 fis.close (); Fos.close () ; }20}FileInputStream and FileOutputStream define decimal groups for read and write operations:1 package Com.ningmeng; 2 3 import java.io.FileInputStream; 4 import java.io.FileOutputStream; 5 6 public class Filetest {7 8 PU Blic static void Main
classification of Java IO streamsstreams in Java can be categorized from different angles. Sort by flow: input stream: The stream from which the program can read data.Output stream: The stream to which the program can write data.
program to provide powerful, flexible read and write functions. 1.2, Java.io Common classAll stream classes provided by the JDK are located in the Java.io package, each inheriting from the following four abstract stream classes:InputStream: Streams that inherit from InputStream are used to enter data into the program, and the Data units are bytes (8-bit).Outputs
and encapsulation of streams, it provides powerful and flexible reading and writing function for the program by processing the data. 1.2, Java.io Common classAll stream classes provided by the JDK are located in the Java.io package, each inheriting from the following four abstract stream classes:InputStream: Streams that inherit from InputStream are used toinput Data, and the dataunits are bytes(
then written)7FileOutputStream OutputStream =NewFileOutputStream (file,true); 8 9 //3. Create a byte array of keysTenString str = "Hello word"; One //Changing a string into a byte array A byte[] B =str.getbytes (); - - //4. Writing Data theOutputstream.write (b);//Hello Word - - //5. Close Resources - outputstream.close (); + -}
Mo Mo sa
): Constructs a FileWriter object based on the given file name.FileWriter (String filename, boolean append): Constructs a FileWriter object based on the given file name and a Boolean value that indicates whether to append the data.Member method: The member method of the parent class () does not have its own member method6/2 FileReader (character stream, basic stream)---> InputStreamReader sub-classConstruct
path, but pass a OutputStream object?A: The reason is simple, the byte buffer stream only provides buffers, designed for efficiency. However, the actual read and write operation is also dependent on the basic flow object implementation.3. Bufferedoutputstream Write Data , code example:1 Packagecn.itcast_05;2 3 ImportJava.io.BufferedOutputStream;4 ImportJava.io.FileOutputStream;5 Importjava.io.IOException;6 7 Public classBufferedoutputstreamdemo {
1. Print Flow(1) Classification:• Byte print stream PrintStream • character print stream PrintWriter(2) Characteristics of the print flow:• can only write data , cannot read data• Only the destination can be manipulated and the data source cannot be manipulated • can manipulate any type of data • automatically refresh if automatic refresh is enabled • the ability to manipulate text files directly(3) Att
Differences between byte stream and byte stream storage in Java, using several common types of data to compare the differences between byte stream and byte streamInt A = 5;Boolean B = true;Char c = 'G ';String d = "hello ";Print the data of the above types to the file using the ghost stream:Printwriter dos = new printw
I. Input/output stream
1. Stream: Different types of input, output source data streams: input or output data
All of the interfaces and classes of the Java data stream are defined in the Java.io package, so you should add them at the beginning of the program
Import java.io.*
2. Classification of str
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.