File stream (File) IO

Here Insert Picture Description
File stream (File) IO
flow refers to the flow of a series of characters, based on the FIFO method to send channel information.
8 is a generic byte stream byte stream,
a character stream is a Unicode character stream 16
a, File :
File type of access the file attributes.
File f1 = new new File ( "E: / bbb");
f1.mkdir (); created in the root directory folder
File
file.createNewFile create a file
file.delete delete files
file.exists existence of a file
file.ifFile whether the file
if the directory is file.ifDirectory
file.getPath relative path
file.getAbsolutePath absolute path
file.getName filename
file.length file size
file.close closed
two, read and write files :
the byte stream of
the input stream: the FileInputStream
output streams: a FileOutputStream
character stream
input stream: FileReader
output stream: FileWriter
the buffer flow
Input stream: BufferedReader
output stream: BufferedWriter,
. 1, read and write text file
using a text file read and write FileInputStream and FileOutputStream.
BufferedWriter with BufferedReader and read and write text files.

FileInputStream read a text file using
the steps of:
1, related to the introduction of class
2, the configuration of the object FileInputStream file input stream
3, a text file to read data
4, close the file stream object

FileOutputStream write a text file using
the steps of:
1, related to the introduction of class
2, FileOutputStream file output stream
. 3, the data is written to a text file
4, close the file stream object

BufferedReader read a text file using the
steps of:
1, related to the introduction of class
2, and the configuration of the object BufferedReader
FileReader objects
3, calls the readLine () method of reading data
4, close file stream object
InputStream class common methods
subclass FileInputStream conventional construction method

The FileInputStream (File File)
the FileInputStream (String name)
the OutputStream class common method
void Write (int C)
void Write (byte [] buf)
void Write (byte [] B, int OFF, int len)
void Close ()
subclass FileOutputStream common the construction method of
a FileOutputStream (File File)
a FileOutputStream (String name)
a FileOutputStream (String name, Boolean the append)
Writer class common method
Write (String STR)
Write (String STR, int OFF, int len)
void Close ()
void the flush ()
sub class BufferedWriter conventional construction methods
BufferedReader (Writer OUT)
Reader class common method
int Read ()
int Read (byte [] C)
Read (char [] C, int OFF, int len)
void Close ()
subclass BufferedReader common configuration method
BufferedReader (Reader in)
subclass-specific methods BufferedReader
the readLine ()
2, reading and writing binary file
using the DataOutputStream DataInputStream and write binary files.
Third, using the file stream step
1, related to the introduction of class
2, the input stream created / l output stream object
3, the read / write data of the text file
4, to close the associated stream object

Published 31 original articles · won praise 0 · Views 356

Guess you like

Origin blog.csdn.net/weixin_45864941/article/details/103897955