This chapter covers the changes to the java.io package in Java 9.
InputStream
The class java.io.InputStream adds
three methods for reading and copying data from the input stream
.
- readAllBytes() : Reads all remaining bytes from the input stream.
- readNBytes (byte[] b, int off, int len): Reads the given number of bytes from the input stream into the given byte array b. offset is the reading position, while len is the number of bytes to read.
- transferTo (OutputStream out): Reads all bytes from the input stream and writes to the given output stream.
In Listing 12-1, the file input.txt contains the content “Hello World”. ...