Chapter 5 file and data flow of JAVA programming

Source: Internet
Author: User

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.

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.