Outline:
1) Introduction to files and data streams:
Classes for I/O processing are mainly included in java. io packages, and common base classes mainly include processing byte
InputStream, OutputStream, and Reader and Writer classes that process characters and their base classes.
Class for standard input output and error output: System. in System. out System. err.
To redirect.
Data streams are a series of data. files are stored on storage media for a long time.
File is the object associated with the byte data stream. JAVA regards the File as a byte stream and creates the object upon opening the File.
File object and associate the data stream.
2) input stream and output stream (for byte stream)
Classes for processing files in the java. io package include:
A) FileInputStream class for reading file data in bytes; write data in bytes
To the FileOutpuStream class in the file; and random access to the file class RandomAccessFile
Class.
B) The DataInputStream and DataOutputStream classes not only provide reading and writing of Basic Data Types
And also supports reading and writing String data. This class provides many methods.
C) The BufferedInputStream class and BufferedOutputStream class provide input with cache.
Output stream.
Mainly through the construction of these classes to establish the association between files and class objects, so as to achieve through the class
To Read and Write File data. Pay attention to the parameters required by the constructor of different classes.
3) Reader (based on characters)
The FileReader class that reads file data in characters. Data is written to the file in characters.
Filewriter class, bufferreader and bufferwriter class with cache,
Inputstreamreader serves as a bridge between inputstream and reader.
Outputstreamwriter.
4) Other classes
The Java. Io. File class provides file-related information and does not open or process the file.
Objectinputstream and objectoutputstream are used to read and write various status values of instance objects.
.
Note that you can use try catch block to generate an object.