I. What is I/O, stream
I/O is the input and output of data
A stream is a sequence of data
II. Basic Class library structure of I/O
1, byte-based operation of I/O interface: InputStream outputstream
2, character-based operation of the i/0 interface: Writer Reader
3. i/0 interface based on file operation: Files
4. Network operation-based I/O interface: Socket
three, disk I/O working mechanism
1. Read and Write files: Memory cache mechanism: When reading a file, first see if the data exists in the memory cache, the presence is directly loaded into the user space
2. Standard Access file mode
(1) Check that the kernel cache space is present when read, then return, no read disk is loaded into kernel space
(2) When the write is copied from the user address space to the kernel address space cache, the write operation completes, writes to the disk is the system responsibility, unless the explicit call sync ()
3. Direct I/O mode
(1) The application directly accesses the disk data and reduces the replication of the kernel-to-user space data once
(2) This type of loading is slower and is generally used in conjunction with asynchronous I/O
4. Memory Mapping method
(1) Memory mapping refers to the location of the file on the hard disk with the same size as a block in the logical address space in the process, the Access file is converted to access the file
(2) Suitable for large amount of data transmission
Iv. accessing disk files
1, the file in Java is not a real object, the return is a FileDescriptor object, operation generated Streamdecoder object to specify the encoding
v. Java serialization Technology
1, Serialization: Convert an object into a string binary representation of the byte array, by saving or transferring byte data to achieve the purpose of persistence
2, Serialvesionuid:
(1) ensure the compatibility of the serialized version "The object is modified after serialization, and if no UID is specified, the deserialization error"
(2) Default Serialversionuid: Calculates a unique variable value based on class, attribute, method
3. Applicable:
(1) The session object is saved on the web, and Tomcat stores the session as a Session.ser object when the server shuts down, called the session passivation
(2) Transmission of network objects
vi. working mechanism of network i/0
Bio/nio/aio