Use of output stream outputstring() of Java IO stream

Fileoutputstream: subclass, write out the channel of data

Steps:

    1. Get target file

    2. Create a channel (if there is no target file, one will be created automatically)

    3. Write data

    4. Release resources

Note:

(1) if the target file does not exist, it will create a target file by itself

(2) if the target file exists, clear the data in it first, and then write the data

(3) if you want to write data on the original data, use the construction method when creating the channel:

OutputStream (file, Boolean append). If the Boolean value is true, it is OK

(4) write data with the write (int a) method. Although int is received, there is actually only one byte of data

(the lower eight bits are operated, and all others are discarded)

//会自动导入一些包
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>