Java byte stream and character stream including the stream, byte stream through the IO device to read bytes of data the way, while the character stream is read into the data through the byte stream into a character "flow" in the form of user-driven.
Flow through the expansion of packaging functions, such as BufferedStream, can buffer streams, improve reading performance, in fact, are based in Java, this operation IO's.
But we can not BufferedStream is actually available as a stream, in fact, they must be packing a representative of the real IO stream users to operate equipment, such as System.in and System.out, or arrays and strings (another package's stream ).
InputStream can be used for example:
InputStream in = new BufferedInputStream (new BufferedInputStream (System.in));
The character stream it?
In fact, no real character in the form of flow only through the packaging of some special characters in the input stream to carry out operations, such as packing a byte stream InputStream:
Reader reader = new InputStreamReader (System.in);
Suppose, for example packaging the character array:
char [] in = new char [1024];
Reader reader = new CharArrayReader (in);
Understand, the law can understand the flow of operation.
没有评论:
发表评论