Using the Byte Streams

We will begin our examination of Java’s I/O with the byte streams. As explained, at the top of the byte stream hierarchy are the InputStream and OutputStream classes. Table 10-3 shows the methods in InputStream, and Table 10-4 shows the methods in OutputStream. In general, the methods in InputStream and OutputStream can throw an IOException on error. The methods defined by these two abstract classes are available to all of their subclasses. Thus, they form a minimal set of I/O functions that all byte streams will have.

Image

Table 10-3 The Methods Defined by InputStream

Table 10-4 The Methods Defined by OutputStream

Reading ...

Get Java, A Beginner's Guide, 5th Edition, 5th Edition 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.