Performing I/O in Java

This section shows how to perform several important tasks in Java using streams and Readers and Writers, including

  • Byte-oriented I/O

  • I/O with Java Primitives

  • Write and read lines of text

  • Write and read entire objects

Performing I/O Using FileInputStream and FileOutputStream: Code Example

FileInputStream and FileOutputStream are the basic, concrete classes for doing I/O. Despite their names, you do not need to use them for writing to or reading from files as such. You should select the stream, Reader, or Writer that you want to use based on the granularity or level of abstraction you want to work at. You choose FileInputStream and FileOutputStream to work at the byte level. Listing 12.3 shows a simple example of using these ...

Get PURE Java™ 2 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.