Java I/O

[ Table of Contents | Examples | Index | Errata | Broken Links | Updates | Why I Like Writing for O'Reilly | Interview with Peter Wayner | Top Ten Myths about Java I/O | Order ]
Book Cover, PlayDo Press

Update: The second edition of the Java I/O has been published. I'm keeping this page here to support readers who bought the first edition, as well as for readers of translations, since many of the translations are still based on the first edition. However, if you want the most current information, you should go to the second edition page instead.

The second edition is substantially improved over the second edition with lots of new and updated material. New topics include Java 1.4, 5, and 6, including the New I/O APIs, Bluetooth, USB, and J2ME. It is completely up-to-date with the state of the art in Java as of Java 6. If you're buying a new copy, you'll want to make sure you get the second edition. It's the one with the rabbit on the cover.

What a long strange trip this book has been. When I began writing the first draft back in September, 1997, I thought it would take me about two months and 200 pages. Now, a year and a half and 600 pages later, I've learned that I/O is a much bigger, more interesting, and more important topic than I originally dreamed. But I have managed to create what is unquestionably the best book I've ever written, and one in which I expect that all Java programmers will find something worthwhile, so I hope you won't mind if I take a few minutes to tell you about this book.

Java's input and output libraries have been unfairly maligned for some time. It is widely (but incorrectly) believed that I/O in Java is a lot weaker and a lot harder than I/O in traditional languages like C, C++, and Pascal. If anything, however, the exact opposite is true. Java's I/O tools are far more sophisticated, more powerful, and easier to use than traditional printf()/scanf() style I/O.

Java's input and output (I/O) is based on streams. Streams are a convenient metaphor for reading and writing data regardless of whether that data comes from a file, a network connection, the console, another thread, or some other source. Furthermore streams can be filtered to perform encryption, serialization, compression, translation, and other services.

Java I/O tells you all you need to know about the four main categories of streams and uncovers less known features to help make your I/O operations more efficient. Plus, it shows you how to control number formatting, use characters aside from the standard ASCII character set, and get a head start on writing truly multilingual software.

I/O in C, C++, and most other languages, is hamstrung by the assumption that what's being read or written is a 1970s era dumb terminal, or at least something very much like it. Java is the first major language to throw out this assumption. The designers of Java recognized that programs that read and write files, network connections, and serial port devices are a lot more important than toy programs from CS101 that read a number from the command line and square it. Consequently they created a language that focuses on solving professional programmers' real problems, instead of CS101 textbook examples. Rather than copying old-fashioned I/O APIs based on dumb ASCII terminals from the 1970s or DOS prompts from the 1980s, Java's designers created a new I/O API based on abstract streams. This API better suits the international network programs of the 1990s.

Unfortunately, precisely because Java I/O is structured so differently from I/O in the languages most of us grew up with, many programmers don't realize how simple and powerful it really is. I first noticed this after I wrote Java Network Programming. Many of the questions I got from readers weren't about network programming at all. They were about I/O. That's when I began thinking seriously about writing a prequel to Java Network Programming; a book that would cover the package and show programmers how to really take advantage of Java's I/O facilities to write very powerful programs far more quickly than they could in any other language. Java I/O is that book.

Here are just a few of the topics covered in depth in Java I/O:

And that's really just the beginning of what you'll learn from Java I/O. I'm really happy with this book. In fact it's perhaps the first book I've written that I really feel reached its full potential. I do hope you'll check it out. It's available from, Fat Brain, and other purveyors of fine computer books. If you need to special order it, the ISBN number is 1-56592-485-1. It's $32.95, 596 pages, published by O'Reilly, and written by me, Elliotte Rusty Harold.

Table of Contents

Part I: Basic I/O
1. Introducing I/O 2. Output Streams 3. Input Streams
Part II: Data Sources
4. File Streams 5. Network Streams
Part III: Filter Streams
6. Filter Streams 7. Data Streams 8. Streams in Memory 9. Compressing Streams 10. Cryptographic Streams
IV. Advanced and Miscellaneous Topics
11. Object Serialization 12. Working with Files 13. File Dialogs and Choosers 14. Multilingual Character Sets and Unicode 15. Readers and Writers 16. Formatted I/O with java.text 17. The Java Communications API
Part V: Appendixes
A. Additional Resources

B. Character Sets

[ Cafe au Lait | Examples | Corrections | Index | Broken Links | Updates | Why I Like Writing for O'Reilly | Interview | Order ]

Copyright 1999 Elliotte Rusty Harold
Last Modified August 22, 2006