<>1. Java There are several types of flows in ?

* Character stream and byte stream .

* Byte stream inheritance inputStream and OutputStream
* Character stream inherited from InputSteamReader and OutputStreamWriter
* General structure

<>2. Which is better, byte stream or character stream ? How to choose ?

* Slow byte stream is better in most cases , Because a byte stream is a wrapper for a character stream , And most of the time IO
Operations are all direct operations on disk files , So these streams are transmitted in bytes ( Pictures are stored in bytes )
* If you need to pass the IO It is better to use character stream when string is processed frequently in memory , Because character streams have buffers , Improved performance
<>3. What is a buffer ? What's the role ?

Buffer is a special memory area , In many cases, when a program needs to operate a resource frequently ( Such as file or database ) The performance will be very low , Therefore, in order to improve the performance, some data can be read and written to the cache temporarily , Read and write data directly from this area in the future , This significantly improves sex .
* about Java The operation of character stream is in buffer , So if we want to actively refresh buffer to file in character stream operation, we can use flush() Method operation .
<>4. What is the difference between character stream and byte stream ?

The use of character stream and byte stream is very similar , But in fact, the operation of byte stream does not pass through the buffer ( Memory ) It's a direct manipulation of the text itself , The operation of character stream will go through the buffer first ( Memory ) The file is then manipulated through the buffer

<>5. What is? Java serialize , How to achieve Java serialize ?

Serialization is a mechanism for processing object streams , To stream the contents of an object . Can read and write to the object after convection , Streaming objects can be transferred between networks . Serialization is to solve the problems caused by the read and write operations of the object stream
Implementation of serialization : Class implementation that will need to be serialized Serialize Interface , There is no way to achieve it , This interface is only used to annotate objects that can be serialized , Then use an output stream ( as :FileOutputStream) To construct a ObjectOutputStream( Object flow ) object , Reuse ObjectOutputStream Object's write(Object
obj) Method to set the parameter obj Object write out
<>6. PrintStream,BufferedWriter,PrintWriter Comparison of ?

PrintStream Class output is very powerful , Usually if you need to output text content , The output stream should be wrapped as PrintStream Output after . It also provides two other functions . Different from other output streams ,PrintStream
Never throw IOException; But , Exceptions can only be set through checkError Internal flag of method test . in addition , For automatic refresh , You can create a
BufferedWriter: Write text to character output stream , Buffer individual characters to provide a single character , Efficient writing of arrays and strings . adopt write() Method to output the obtained characters , And then through newLine() Line feed operation .BufferedWriter The character stream in must be flush Method to brush it out . also BufferedWriter Only character streams can be operated on . If you want to operate on a byte stream , Use BufferedInputStream
PrintWriter Of println Method to automatically add line breaks , Do not throw exceptions , If you care about abnormality , Call required checkError Method to see if there is any abnormality ,PrintWriter Constructor can specify parameters , Auto refresh cache (autoflush)
<>7. BufferedReader What kind of stream does it belong to , What is it mainly used for , There are some classic methods in it ?

Belongs to the buffer stream in the processing stream , The read content can be stored in memory , Yes readLine() Method , it , Used to read a row

<>8. What is node flow , What is processing flow , What's the use of each of them , What are the characteristics of process flow creation ?

* Node flow Connect directly to the data source , For input or output
* Process flow : Machining on the basis of node flow , Expand some functions
* The constructor that processes the flow must Subclass of incoming node flow
<>9. Flow generally needs to be closed , What method is used if it is closed , It's better to close it in that code block , How is the process flow closed , How to close if there are multiple flows calling each other and passing in ?

* Once the stream is open, it must be closed , Use close Method
* Put in finally In statement block (finally Statement will execute )
* The called handler closes the handler
* Multiple flows call each other to close only the outermost flow
<>10. InputStream Li read() What is the return ,read(byte[] data) What do you mean? , What value is returned ?

* Returns the bytes read int type ( Range 0-255)
* read(byte [ ] data) Store the bytes read in this array . What is returned is the number of passed in array parameters
<>11. OutputStream Inside write() What do you mean? ,write(byte b[], int off, int
len) What are the three parameters in this method ?

* write Pass the specified byte to the data source
* Byte b[ ] yes byte array
* b[off] Is the first character passed in ,b[off+len-1] Is the last character passed in ,len Is the actual length

©2019-2020 Toolsou All rights reserved,
JS How to operate C Language console games , Make bricks use Python Do automated testing (pytest The essence of framework ) First knowledge MySQL Comprehensive review ( dried food )Python+OpenCV Detailed explanation of face recognition technology Baidu , Ali , Tencent's internal position level and salary structure , With job suggestions ! Image explanation of over fitting and under fitting Huawei certification HCIA-AI artificial intelligence New York Youth Project “ Recapture Wall Street ”: Safeguarding the interests of retail investors CSS architecture design