© Fu Cheng 2018
Fu ChengExploring Java 9https://doi.org/10.1007/978-1-4842-3330-6_12

12. I/O

Fu Cheng
Auckland, New Zealand
This chapter covers the changes to the java.io package in Java 9.


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”. ...

Get Exploring Java 9: Build Modularized Applications in Java now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.