The tenth week Lessons Learned

The tenth week Lessons Learned

First, the RandomAccessFileclass

Uses: Fileclass file itself is only performed for the operation, and if you want to manipulate the contents of a file, you can use the RandomAccessFileclass, which belongs to the class of random read, random read data file in a specified location.

RandomAccessFileCommon methods of operation class:

Note: If the rwfashion statement RandomAccessFilewhen the object to be written to the file does not exist, the system will automatically be created.

Second, the byte stream and character stream

Flow: all data is transmitted in a streaming manner or in a program stored in the program data to be used when necessary to read the input data stream, and when the program needs to be saved in some data, it is necessary to use the output stream carry out. As shown below:

Definitions: In the java.iooperation of the packet flows mainly byte stream and character stream into two categories, there are two types of input and output operations. Output data is mainly used in the byte stream OutputStreamclass is completed, using the input InputStreamtype, the output is mainly in the character stream Writerclass completed, input primarily using Readerclass completed.

Protocol: In Javathe IOoperating step is also appropriate to operate the files as an example, the main procedure is as follows:

(1) using the Fileclass to open a file.

(2) specify the location of the output byte stream, or by subclassing the character stream.

(3) read / write operation.

(4) closes the input / output.

Byte stream

The main operation is byte stream bytetype data to bytean array prevail, the operation is the main OutputStreamclass and the InputStreamclasses.

Guess you like

Origin www.cnblogs.com/lcbxhda/p/11762181.html