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
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
)); System.out.println (Personmap.tostring ()); //4, List to Map,key value of Id,value for nameMapPersionlist.stream (). Collect (Collectors.tomap (Person::getid, person::getname)); System.out.println (Namemap.tostring ()); }}Operation Result:is not before a few layers of the for loop to solve the problem, through the stream as long as a line of code can be resolved.Note that if you li
1 Packagefile operation;2 3 ImportJava.io.File;4 ImportJava.io.FileReader;5 Importjava.io.IOException;6 ImportJava.io.Reader;7 8 Public classTestreader {9 Public Static voidMain (string[] args)throwsIOException {TenFile file=NewFile ("D:" +file.separator+ "Test.txt"); One /*File*/Reader reader=NewFileReader (file);//you can also receive instantiated objects directly with a variable of type FileReader, without using an upward transformat
A thorough understanding of Java I/O Systems
I. Input and Output1. Stream represents any data source capable of producing data or any receiving source capable of receiving data. In Java I/O, all streams (including input and out stream) have two types:1.1 byte-oriented streamA byte-oriented
Reference Blog: HTTPS://WWW.JIANSHU.COM/P/9FE8632D0BC2About Stream
Java 8 introduces a new stream API. This stream differs from the I/O stream in that it is more like a collection class with iterable, but behaves differen
);System.out.println(y);System.out.println(z);dis.close();
14. Io Stream (Overview of the properties and use as a map collection)
Overview of A:properties
The Properties class represents a persistent set of attributes.
Properties can be saved in a stream or loaded from a stream.
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,
is, if the character data in the file in A.txt is encoded by UTF-8, then the encoding table must be specified when reading, so it is necessary to convert the stream.namely: InputStreamReader isr=new InputStreamReader (New FileInputStream ("A.txt"), utf-8);Classes or interfaces related to Java stream operations:Java Fl
. 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
Update Time: 2018-1-7 12:27:21For more information, see the online anthology: http://android.52fhy.com/java/index.html
java.ioThe package contains almost all the required classes for operation input and output. All of these flow classes represent the input source and output destination.Introduction to input and output streamsA stream is defined as a data series. The input
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
readAllLines (Path path, Charset cs) method. This method is similar to the previous method, and you do not need to close the file after reading the file. However, it returns a string array instead of a byte array. Furthermore, Java 8 overrides this method and directly uses UTF-8 encoding for String Conversion without specifying character sets.If you want to read
IO stream 05 -- video Study Notes for bixiangdong JAVA basic tutorial, 05 -- bixiangdong
Day20
10 create a java file list11 Properties12 Properties access13 Properties14 Properties exercises15 PrintWriter16 merge streams17. Cut files
10 create a java file list
Exercise:Store the absolute path of a
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.