IO Flow face Test

Source: Internet
Author: User
Tags object serialization readline serialization what interface
1, what is bit, what is byte (byte), what is the character (Char), how long they are, what is the difference

Bit is bit bit, is the smallest binary unit of the computer, takes a value of 0 or 1,

Byte occupies 8 bits, takes value -128~127

Char occupies two bytes, 16 bits, and takes value 0~65535

bit is the smallest unit of data storage, and computers only know 0 and 1

Byte is the basic unit of computer storage capacity

Char is a basic data type of Java 2, what is a stream, according to the unit of transmission, which two streams are divided into

The input and output of data in a Java program is called a stream

Divided into byte stream and character streams

Byte throttling: InputStream OutputStream

Character stream: Reader Writer 3, the flow according to the direction of transmission can be divided into which two, respectively, illustrate

Input stream InputStream

Output stream OutputStream 4, according to the implementation of the flow of the two types, respectively, illustrated

Node Flow: OutputStream

Processing flow: OutputStreamWriter (Byte-stream character stream) 5, BufferedReader belong to what kind of flow, it is mainly used to do what, it has those classical methods

is a buffer stream in the processing stream, which reads text from the character input stream and is localized for the program used for text entry. Can be read content in memory, there are ReadLine () method 6, what is the node flow, what is the processing flow, what they are useful, the processing of the creation of the flow characteristics

 node Flow: Directly connected to data source for data input and output
  Processing flow: The encapsulation of the node flow, the function extension, the processing flow of the construction method is always passed into the node stream subclass
  Feature: The constructor of the processing stream must pass in the subclass of the node stream
7, if I want to do a lot of byte stream from the hard drive to read, to use that stream, why

bufferedinputstream Use buffer flow can reduce the damage to the hard disk 8, if I want to print out different types of data to the data source, then the most appropriate stream is that flow, why

PrintWriter can print a variety of data types 9, how to change the output of our console to output to a file inside, this technology called What

SetOut redirect 10, How to change the output byte flow into the stream of output characters, to tell its steps

OutputStreamWriter can stream bytes into character streams

New OutputStreamWriter (Newfileoutputstream (""));

11, in order to include the basic types of data and strings output to the data source, or in order from the data source read, generally use which two streams

DataInputStream DataOutputStream
12. Write an object to a data source or read it from a data source, with which two streams
ObjectInputStream deserialization of ObjectOutputStream serialization
13, what is called object serialization, what is deserialization, implementation of object serialization need to do what work

Object serialization is to save an object in binary form on a hard disk

Deserialization converts an object binary file saved on a hard disk into an object read to a program

Need to implement serializable interface, do not want to put a field on the hard disk, add transient modifier to the field


14


15 in the implementation of the serialization interface is generally to generate a serialversionuid field, what it is called, what is commonly used

 is the version number,
Keeping the version number consistent for serialization can prevent serialization errors
16, what is the return of Read () in InputStream, what is the meaning of read (byte[] data), what value is returned

Returns the read byte int (range 0-255)

Byte[] Stores the read byte data in this array

Returns the total number of bytes read into the buffer, or 1 if no more data

17, OutputStream inside the write () is what meaning, write (byte b[], int off, int len) This method inside of the three parameters respectively what meaning

Write writes the specified byte to the data source
BYTE b[] is a byte array, and the destination array
B[off] is the first character passed in
B[off+len-1] is the last character passed in
Len is the actual length
18, the flow of general needs do not need to close, if the closed words in what method, the general to be in that code block inside close better, how to deal with the flow is closed, if there are multiple streams to each other to call the incoming is how to close.
The stream must be closed once it is opened, using the Close method
into a finally statement block (the finally statement must be executed)
(The calling processing stream closes the processing stream) calls the Close method
Multiple streams call each other to close only the outermost stream
19, all the streams in Java can be divided into several categories, what their name is, what each Representative
BYTE output stream OutputStream
Character input stream Reader
Character output stream Writer
All streams are subclasses of these four streams
20, Io stream How to read the file.
Defines a filereader character input stream, passes in the file path, uses the character cache stream BufferedReader to handle the FileReader, and then defines a method that the string is used to receive BufferedReader Readerline read the file line by row
21. Tell me about your understanding of Io flow
IO flow is mainly used to deal with input and output problems, commonly used IO stream has inputstream,outputstream,reader,writer, etc.
22, Java IO Flow and ReadLine method
ReadLine is a method in BufferedReader that reads a line of text. The end of a row is judged by a newline (' \ n '), carriage return (' \ R '). If the end of the stream is reached, NULL is returned.
23, with what the object is dynamically written to disk, write to implement what interface.
ObjectInputStream for deserialization requires implementation of the Serializable interface
24, FileInputStream Create details, is how to create a no error, it lists several forms!
FileInputStream is a subclass of InputStream that is created by interface definitions, subclass implementations FileInputStream
25, I ask you under what circumstances will be in your Java code to use serializable. How to implement Java serialization.
To write an object to a data source or read it from a data source, using serializable, you need to implement the Serializable interface

Related Article

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.