Java. io. Reader and java. io. InputStream constitute Java input classes. Reader is used to read 16 characters, that is, Unicode-encoded characters. InputStream is used to read
Input ASCII characters and binary data.
In Java, different types of Reader input streams correspond to different data sources:
FileReader is used for input from a file;
CharArrayReader is used to input character arrays from the program;
StringReader is used to input strings from the program;
PipedReader is used to read data written to the pipeline from PipedWriter in another thread.
Different types of InputStream input streams correspond to different data sources: FileInputStream, ByteArrayInputStream, StringBufferInputStream,
PipedInputStream. In addition, there are two InputStream input streams that do not have the corresponding Reader type:
Socket is used for sockets;
URLConnection is used for URL connection.
These two classes use getInputStream () to read data.
Correspondingly, there are similar differences between java. io. Writer and java. io. OutputStream.