Java I/O (O'Reilly Java)
 

Related Products













Java I/O (O'Reilly Java)

by Elliotte Rusty Harold

buy from amazon.com
Average Rating: * * * * -
Sales Rank:1237221 (lower is better)
Price Used:$4.62
Shipping:Free Shipping on most orders over $25*
Availability:
Pages:596
Binding:Paperback
Publication Date:1999-02-28
ASIN:B00007FYHS
Category:Book

Authors

Editorial Reviews and Product Descriptions

Product Description

All of Java's Input/Output (I/O) facilities are based on streams, which provide simple ways to read and write data of different types. Java provides many different kinds of streams, each with its own application. The universe of streams is divided into four large categories: input streams and output streams, for reading and writing binary data; and readers and writers, for reading and writing textual (character) data. You're almost certainly familiar with the basic kinds of streams--but did you know that there's a CipherInputStream for reading encrypted data? And a ZipOutputStream for automatically compressing data? Do you know how to use buffered streams effectively to make your I/O operations more efficient? Java I/O, 2nd Edition has been updated for Java 5.0 APIs and tells you all you ever need to know about streams--and probably more.

A discussion of I/O wouldn't be complete without treatment of character sets and formatting. Java supports the Unicode standard, which provides definitions for the character sets of most written languages. Consequently, Java is the first programming language that lets you do I/O in virtually any language. Java also provides a sophisticated model for formatting textual and numeric data. Java I/O, 2nd Edition shows you how to control number formatting, use characters aside from the standard (but outdated) ASCII character set, and get a head start on writing truly multilingual software.

Java I/O, 2nd Edition includes:

  • Coverage of all I/O classes and related classes
  • In-depth coverage of Java's number formatting facilities and its support for international character sets
Amazon.com Review

Because it doesn't provide a printf() function like C/C++, some developers think Java isn't up to snuff with files and streams. Author Rusty Harold Elliotte argues against this notion in Java I/O, a book that shows how Java's stream support can help simplify network programming, internationalization, and even compression and encryption.

The book opens with an overview of Java's stream capabilities. (The author defends Java's lack of support for console input/output (I/O) since today's applications use graphical user interfaces anyway.) He shows how to open, read, and write local files in Java applications. His file viewer example presents data in a variety of formats. (This example is improved several times until it winds up supporting different international character sets by the end of the book.)

Next the author covers network programming using URL and network streams, including sockets. Sections on filters show how classes can filter out characters within streams. The tour moves forward to cover data streams, which permit streaming of Java's primitive data types. Details on how to communicate within Java programs using pipes follow. In a notable chapter, the author thoroughly explicates Java's support for encryption, including hashing, the Data Encryption Standard (DES) algorithm, and ciphers.

The last portion of the book explains object serialization, which allows Java objects to save and restore their state, plus it includes sections on Java's support for data compression (and ZIP files) and multilingual Unicode character sets. (Java is prepared to handle virtually any of the world's languages with its reader and writer classes.) Finally, the author shows how you can format output in Java using its support for width and numeric precision APIs.

In all, Elliotte makes a good case that Java streams are a flexible and powerful part of the language, and certainly not a limitation. --Richard Dragan

Customer Reviews

Java I/O - Reviewed on 2008-03-24
* * * *

Thorough guide to the java.(n)io API. Less useful as a cookbook as the organization of the book follows the API rather than focusing on specific tasks (e.g. how to best copy a file). Could have done without some of the cool chapters such as the one on J2ME (better treated in other books), or the one that describes hooking up a temperature sensor via USB, or a GPS via Bluetooth (publish these projects in a blog). Could also cut the rants about how outdated command line applications are, and I don't think the Swing-based file browser application that's built up throughout the book adds much. On the other hand I'd rather have more on performance considerations and error handling strategies!
Far better resources available - Reviewed on 2007-06-17
* *
1 customer found this review not to be helpful.
It covers a lot of topics but I did find it particularly helpful in any way. The idea of gathering all the information about I/O into one book to use as a single resource is nice, but this book doesn't do a good job. Not that much help in explaining things and no help at all as far as practical examples went. You will learn much more from general Java books and Google searches.
HAVE A CUP OF JAVA I/O!! - Reviewed on 2006-11-04
* * * * *

Howell do you know I/O? If you don't know it very well, then this book is for you. Author Elliote Rusty Harold, has done an outstanding job of writing a 2ndedition of a book that shows you the I/O tricks and techniques used by gurus and wizards of the Java world.

Harold, begins with an exploration of I/O in Java. Then, the author discusses the two most common targets of I/O, the filesystem and the network. Next, he discusses filter streams, which are Java's mechanism for processing data as you read or write rather than doing it after the fact. The author also discusses a completely new I/O model based on channels and buffers instead of streams. He continues by discussing operations on files themselves as distinct from the contents of those files. Then, the author explores how text is represented in Java and how it can be manipulated through special text streams called readers and writers. Finally, he shows you how to communicate with different kinds of peripherals and small devices that don't have traditional filesystems or network connections..

This most excellent book assumes you have a basic familiarity with Java. More importantly, this book is not a language tutorial, and the emphasis will always be on the I/O-specific features.
Pretty good coverage of NIO and practical crypto - Reviewed on 2006-09-23
* * * * *

Not a fan of O'Reilly books, but this one stands out because of excellent NIO coverage and topical examples. It beats the the "Java NIO" book from O'Reilly hands down. Overall I'd say this book is geared for those who want to implement but covers enough detail that it probably even soothes the more 'academic' out there (those who talk a good show but do not build real-world software).

Some highlights:

- You'll find good coverage of cryptographic I/O aimed at practical implementation.

- Excellent NIO coverage (including basic network servers in sync and async patterns)

- ZIP and JAR information including dynamic class loading

- Serial, USB and Bluetooth chapters (caveat: I don't use these but read them out of curiousity)

- Detailed coverage of readers/writers

- And obviously good coverage of the basic java.io/net packages.

As of Septemebr 2006 I find the book topical and current (even had some examples of future Java 6 code). To give you an idea of the detail offered here, there is a whole chapter (37 pages) of information on File access alone including pitfalls of cross-platform implementation. Not reading/writing files...just the trappings of opening and accessing files and directories using particular patterns, URLs, etc. The actual I/O is covered in similar depth in other chapters.

I'd also like to say that I highly appreciate examples that are concise and independant. There is nothing more frustrating than flipping to the middle of a book (what we all do anyway) and going through an example...only to find out that the author is using opaque references to classes and methods he/she developed on their own in five earlier chapters (bouncycastle APIs in Java Cryto for example). This pretty much makes quick-reference difficult to impossible and this book thankfully avoids it in spades.

I give it five starts because it'll be well used in several projects and because it is readable and accessible to both novice and advanced developers alike.
Great reference for your file input/output logic... - Reviewed on 2006-09-11
* * * * *
1 customer found this review helpful.

[Review of 2nd edition]

Getting data into and out of files in your Java program can be painstaking when you consider all the variations... network resources as files, compressed files, text vs. binary data in the file, etc. Java has significant power in this area, but there's a lot to know and understand. Elliotte Rusty Harold has made the task of learning it all a little easier with the book Java I/O (2nd edition).

Contents:
Part 1 - Basic I/O: Introducing I/O; Output Streams; Input Streams
Part 2 - Data Sources: File Streams; Network Streams
Part 3 - Filter Streams: Filter Streams; Print Streams; Data Streams; Streams in Memory; Compressing Streams; JAR Archives; Cryptographic Streams; Object Serialization
Part 4 - New I/O: Buffers; Channels; Nonblocking I/O
Part 5 - The File System: Working with Files; File Dialogs and Choosers
Part 6 - Text: Character Sets and Unicode; Readers and Writers; Formatted I/O with java.text
Part 7 - Devices: The Java Communications API; USB; The J2ME Generic Connection Framework; Bluetooth
Part 8 - Appendix: Appendix; Index

The first edition of this book was written back in 1999, and that's an eternity in computer years. Not only has the java.nio classes come into play since then, but you now have devices that were either bleeding edge or concept-only in 1999, like Bluetooth gadgets. Harold has improved the basic material to bring it up to date with the current state of Java development, and added the additional information for I/O classes through Java 6. I appreciated the large amount of coding samples that he uses to illustrate his points, as it makes it easy to adapt your learning to your own particular situation. The examples are also very focused, so you don't end up trying to filter out extraneous code to find the applicable concept you need.

There's another way to use this book that makes it even more valuable than just a reference manual. If you've been coding for awhile, it's possible that you've developed some ingrained approaches to file I/O that are outdated. By simply scanning the information here, you could easily find new ways to build your applications using newer methods. Or, you might find there are language features you didn't know existed, like the ability to write your files in a compressed format without having to go through a separate utility. Two or three personal revelations like that, and the book has quickly earned its place on the shelf.

While you may not use this book for every Java application you build, you'll definitely want it whenever you're working with I/O logic...
Read More Customer Reviews »
Go To Amazon Product Page

* - See Amazon Product Page for shipping and pricing details.


Book Subjects