Java I/O


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 largecategories: 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 ...

See more details below
Paperback (Second Edition)
$53.26 price
(Save 11%)$59.99 List Price
Other sellers (Paperback)
  • All (17) from $29.89   
  • New (7) from $38.04   
  • Used (10) from $29.88   
Java I/O

Available on NOOK devices and apps  
  • NOOK Devices
  • Samsung Galaxy Tab 4 NOOK 7.0
  • Samsung Galaxy Tab 4 NOOK 10.1
  • NOOK HD Tablet
  • NOOK HD+ Tablet
  • NOOK eReaders
  • NOOK Color
  • NOOK Tablet
  • Tablet/Phone
  • NOOK for Windows 8 Tablet
  • NOOK for iOS
  • NOOK for Android
  • NOOK Kids for iPad
  • PC/Mac
  • NOOK for Windows 8
  • NOOK for PC
  • NOOK for Mac
  • NOOK for Web

Want a NOOK? Explore Now

NOOK Book (eBook)
$27.49 price
(Save 42%)$47.99 List Price


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 largecategories: 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 automaticallycompressing 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

Updated for Java 5.0 APIs, this volume shows 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.

Read More Show Less

Product Details

  • ISBN-13: 9780596527501
  • Publisher: O'Reilly Media, Incorporated
  • Publication date: 5/23/2006
  • Edition description: Second Edition
  • Edition number: 2
  • Pages: 728
  • Sales rank: 1,025,743
  • Product dimensions: 7.00 (w) x 9.20 (h) x 1.60 (d)

Meet the Author

Elliotte Rusty Harold is originally from New Orleans to which he returns periodically in search of a decent bowl of gumbo. However, he currently resides in the University Town Center neighborhood of Irvine with his wife Beth, dog Shayna, and cats Charm (named after the quark) and Marjorie (named after his mother-in-law). He's an adjunct professor of computer science at Polytechnic University where he teaches Java, XML, and object oriented programming. He's a frequent speaker at industry conferences including Software Development, Dr. Dobb's Architecure & Design World, SD Best Practices, Extreme Markup Languages, and too many user groups to count. His open source projects include the XOM Library for processing XML with Java and the Amateur media player.

Read More Show Less

Table of Contents

What’s New in This Edition;
Organization of the Book;
Who You Are;
About the Examples;
Conventions Used in This Book;
Request for Comments;
Safari Enabled;
Basic I/O;
Chapter 1: Introducing I/O;
1.1 What Is a Stream?;
1.2 Numeric Data;
1.3 Character Data;
1.4 Readers and Writers;
1.5 Buffers and Channels;
1.6 The Ubiquitous IOException;
1.7 The Console: System.out,, and System.err;
1.8 Security Checks on I/O;
Chapter 2: Output Streams;
2.1 Writing Bytes to Output Streams;
2.2 Writing Arrays of Bytes;
2.3 Closing Output Streams;
2.4 Flushing Output Streams;
2.5 Subclassing OutputStream;
2.6 A Graphical User Interface for Output Streams;
Chapter 3: Input Streams;
3.1 The read( ) Method;
3.2 Reading Chunks of Data from a Stream;
3.3 Counting the Available Bytes;
3.4 Skipping Bytes;
3.5 Closing Input Streams;
3.6 Marking and Resetting;
3.7 Subclassing InputStream;
3.8 An Efficient Stream Copier;
Data Sources;
Chapter 4: File Streams;
4.1 Reading Files;
4.2 Writing Files;
4.3 File Viewer, Part 1;
Chapter 5: Network Streams;
5.1 URLs;
5.2 URL Connections;
5.3 Sockets;
5.4 Server Sockets;
5.5 URLViewer;
Filter Streams;
Chapter 6: Filter Streams;
6.1 The Filter Stream Classes;
6.2 The Filter Stream Subclasses;
6.3 Buffered Streams;
6.4 PushbackInputStream;
6.5 ProgressMonitorInputStream;
6.6 Multitarget Output Streams;
6.7 File Viewer, Part 2;
Chapter 7: Print Streams;
7.1 Print Versus Write;
7.2 Line Breaks;
7.3 Error Handling;
7.4 printf( );
7.5 Formatter;
7.6 Formattable;
Chapter 8: Data Streams;
8.1 The Data Stream Classes;
8.2 Integers;
8.3 Floating-Point Numbers;
8.4 Booleans;
8.5 Byte Arrays;
8.6 Strings and chars;
8.7 Little-Endian Numbers;
8.8 Thread Safety;
8.9 File Viewer, Part 3;
Chapter 9: Streams in Memory;
9.1 Sequence Input Streams;
9.2 Byte Array Streams;
9.3 Communicating Between Threads Using Piped Streams;
Chapter 10: Compressing Streams;
10.1 Inflaters and Deflaters;
10.2 Compressing and Decompressing Streams;
10.3 Zip Files;
10.4 Checksums;
10.5 File Viewer, Part 4;
Chapter 11: JAR Archives;
11.1 Meta-Information: Manifest Files and Signatures;
11.2 The jar Tool;
11.3 The java.util.jar Package;
11.4 JarFile;
11.5 JarEntry;
11.6 Attributes;
11.7 Manifest;
11.8 JarInputStream;
11.9 JarOutputStream;
11.10 JarURLConnection;
11.11 Pack200;
11.12 Reading Resources from JAR Files;
Chapter 12: Cryptographic Streams;
12.1 Hash Functions;
12.2 The MessageDigest Class;
12.3 Digest Streams;
12.4 Encryption Basics;
12.5 The Cipher Class;
12.6 Cipher Streams;
12.7 File Viewer, Part 5;
Chapter 13: Object Serialization;
13.1 Reading and Writing Objects;
13.2 Object Streams;
13.3 How Object Serialization Works;
13.4 Performance;
13.5 The Serializable Interface;
13.6 Versioning;
13.7 Customizing the Serialization Format;
13.8 Resolving Classes;
13.9 Resolving Objects;
13.10 Validation;
13.11 Sealed Objects;
13.12 JavaDoc;
New I/O;
Chapter 14: Buffers;
14.1 Copying Files with Buffers;
14.2 Creating Buffers;
14.3 Buffer Layout;
14.4 Bulk Put and Get;
14.5 Absolute Put and Get;
14.6 Mark and Reset;
14.7 Compaction;
14.8 Duplication;
14.9 Slicing;
14.10 Typed Data;
14.11 Read-Only Buffers;
14.12 CharBuffers;
14.13 Memory-Mapped I/O;
Chapter 15: Channels;
15.1 The Channel Interfaces;
15.2 File Channels;
15.3 Converting Between Streams and Channels;
15.4 Socket Channels;
15.5 Server Socket Channels;
15.6 Datagram Channels;
Chapter 16: Nonblocking I/O;
16.1 Nonblocking I/O;
16.2 Selectable Channels;
16.3 Selectors;
16.4 Selection Keys;
16.5 Pipe Channels;
The File System;
Chapter 17: Working with Files;
17.1 Understanding Files;
17.2 Directories and Paths;
17.3 The File Class;
17.4 Filename Filters;
17.5 File Filters;
17.6 File Descriptors;
17.7 Random-Access Files;
17.8 General Techniques for Cross-Platform File Access Code;
Chapter 18: File Dialogs and Choosers;
18.1 File Dialogs;
18.2 JFileChooser;
18.3 File Viewer, Part 6;
Chapter 19: Character Sets and Unicode;
19.1 The Unicode Character Set;
19.2 UTF-16;
19.3 UTF-8;
19.4 Other Encodings;
19.5 Converting Between Byte Arrays and Strings;
Chapter 20: Readers and Writers;
20.1 The Class;
20.2 The OutputStreamWriter Class;
20.3 The Class;
20.4 The InputStreamReader Class;
20.5 Encoding Heuristics;
20.6 Character Array Readers and Writers;
20.7 String Readers and Writers;
20.8 Reading and Writing Files;
20.9 Buffered Readers and Writers;
20.10 Print Writers;
20.11 Piped Readers and Writers;
20.12 Filtered Readers and Writers;
20.13 File Viewer Finis;
Chapter 21: Formatted I/O with java.text;
21.1 The Old Way;
21.2 Choosing a Locale;
21.3 Number Formats;
21.4 Specifying Width with FieldPosition;
21.5 Parsing Input;
21.6 Decimal Formats;
Chapter 22: The Java Communications API;
22.1 The Architecture of the Java Communications API;
22.2 Identifying Ports;
22.3 Communicating with a Device on a Port;
22.4 Serial Ports;
22.5 Parallel Ports;
Chapter 23: USB;
23.1 USB Architecture;
23.2 Finding Devices;
23.3 Controlling Devices;
23.4 Describing Devices;
23.5 Pipes;
23.6 IRPs;
23.7 Temperature Sensor Example;
23.8 Hot Plugging;
Chapter 24: The J2ME Generic Connection Framework;
24.1 The Generic Connection Framework;
24.2 ContentConnection;
24.3 Files;
24.4 HTTP;
24.5 Serial I/O;
24.6 Sockets;
24.7 Server Sockets;
24.8 Datagrams;
Chapter 25: Bluetooth;
25.1 The Bluetooth Protocol;
25.2 The Java Bluetooth API;
25.3 The Local Device;
25.4 Discovering Devices;
25.5 Remote Devices;
25.6 Service Records;
25.7 Talking to Devices;
Character Sets;

Read More Show Less

Customer Reviews

Be the first to write a review
( 0 )
Rating Distribution

5 Star


4 Star


3 Star


2 Star


1 Star


Your Rating:

Your Name: Create a Pen Name or

Barnes & Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation


  • - By submitting a review, you grant to Barnes & and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Terms of Use.
  • - Barnes & reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously
Sort by: Showing all of 2 Customer Reviews
  • Anonymous

    Posted November 3, 2006


    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.

    Was this review helpful? Yes  No   Report this review
  • Anonymous

    Posted December 1, 2009

    No text was provided for this review.

Sort by: Showing all of 2 Customer Reviews

If you find inappropriate content, please report it to Barnes & Noble
Why is this product inappropriate?
Comments (optional)