Share E-Book
Scan to open this page

Scan with your phone to open this page

Author: Elliotte Rusty Harold

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 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 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 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"

AI Reading Assistant

Whole-book reading guide from stratified index samples; jump to passages in the text

AI guide
【One-Line Pitch】 A comprehensive, practical guide to Java’s I/O system—covering streams, filters, character sets, formatting, and serialization—ideal for developers who want to master file, network, and data handling in Java beyond the basics. 【Book Arc】 - **Opening (~0%–9%)**: Introduces the core stream model—input/output streams for binary data and readers/writers for text—along with the fundamental methods of `InputStream` and `OutputStream`, including reading, writing, flushing, closing, and subclassing. Sets up the reader/stream dichotomy that underpins the entire book. - **Early (~9%–22%)**: Explores concrete data sources: file streams (`FileInputStream`, `FileOutputStream`) and network streams (URLs, sockets, server sockets), with practical examples like a File Viewer and URLViewer. Also covers filter streams, including buffered streams for efficiency, and introduces cryptographic streams for hashing and encryption. - **Middle (~22%–35%)**: Delves into advanced topics: object serialization (reading/writing objects, versioning, custom formats), file manipulation (directories, paths, random-access files), and GUI file choosers. Shifts focus to character handling with Unicode, UTF-8, and other encodings, plus readers and writers for text I/O. - **Middle (~35%–48%)**: Covers formatted I/O with `java.text`—number formats, locales, parsing, and decimal formats—and the Java Communications API for serial and parallel port devices. Emphasizes Java’s clean separation between formatting and I/O, contrasting it with C’s `printf()` limitations. - **Late (~48%–57%)**: Reinforces the filter stream architecture, showing how multiple filters chain for encryption, compression, and buffering. Includes a redesigned File Viewer and introduces data streams (`DataInputStream`/`DataOutputStream`) for platform-independent reading/writing of primitive types and strings. 【Key Takeaways】 - **Streams are the backbone of Java I/O** (Early): The four categories—input/output streams for bytes, readers/writers for characters—provide a simple, consistent API for all data sources, from files to networks. - **Filter streams enable powerful transformations** (Early): Chaining filters like `BufferedInputStream` or `CipherInputStream` adds buffering, encryption, or compression without altering the underlying data source, making I/O both efficient and secure. - **Object serialization simplifies persistence** (Middle): Writing objects to streams with `ObjectOutputStream` and reading them back handles complex data structures, but requires attention to versioning and custom formats for long-term stability. - **Character sets unlock multilingual support** (Middle): Java’s Unicode support, including UTF-8 and other encodings, lets you read and write text in virtually any language—a key advantage over ASCII-only systems. - **Formatting is separate from I/O** (Middle): The `java.text` package offers locale-aware number formatting (currency, percentages, precision) that goes beyond `printf()`, and can be extended for custom formats like exponential notation. - **Data streams provide platform-independent data exchange** (Late): `DataInputStream` and `DataOutputStream` handle primitive types and strings in a defined format, ensuring compatibility across systems. - **Network I/O is first-class in Java** (Early): URLs, sockets, and server sockets are fertile sources of streams, enabling web and email clients with minimal code, though the underlying stream types are often hidden in internal classes. 【Reading Tips】 - **Skim the early chapters (1–3)** if you’re already comfortable with basic stream methods; focus instead on the filter stream chapter (6) and the File Viewer examples, which demonstrate practical chaining. - **Deep-read the serialization chapter (11)** if you’re building persistent applications—it covers versioning and custom formats that are easy to get wrong. - **Pay special attention to the character sets chapter (14)** if you handle international text; the differences between UTF-8, Unicode escapes, and other encodings are crucial for avoiding data corruption. - **Use the File Viewer program as a running case study**—it evolves across chapters, showing how to apply new concepts (filters, readers, GUI) to a real tool. - **Skip the Java Communications API (17)** unless you work with serial/parallel ports; it’s niche and less relevant for modern web or cloud development. 【Coverage Limits】 This guide synthesizes the book’s structure and key themes from the excerpts, but does not cover every class or example in detail—particularly the appendixes on resources and character sets, which are referenced but not fully excerpted.
Page 2
ovide simple ways to read and write data of different types. Java™ I/O tells you all you need to know about the four main categories of streams and uncovers...
View in text
Page 4
ographic Streams ....................................... 10.1 Hash Function Basics ....................................... 10.2 The MessageDigest Class ........
View in text
Page 8
and easily write programs that accomplish many common tasks. Some of these include: • Reading and writing files • Communicating over network connections • Fi...
View in text
Page 9
ever. Mainly, this is because MacOS X has Unix at its heart. However, Apple at least has the good taste to hide the shell so it won't confuse end users and t...
View in text
Page 12
archives and to display PNG images. However, the java.util.zip classes are more general than that, and can be used for general-purpose compression and decomp...
View in text
Excerpt 6
e this class and its subclasses for traditional tasks, like Java I/O 7 lining up the decimal points in a table of prices, and nontraditional tasks, like form...
View in text
Page 17
irst example. Therefore, I chose the marginally slower form. Other, still less obvious optimizations are also possible, but would only make the code even mor...
View in text
Page 19
ts Many people were involved in the production of this book. All these people deserve much thanks and credit. My editor, Mike Loukides, got this book rolling...
View in text
Tags
AI categories
Programming LanguageJavaBackend
ISBN: 1565924851
Publisher: O'Reilly
Publish Year: 1999
Language: English
Pages: 479
File Format: PDF
File Size: 2.1 MB
Text Preview (First 20 pages)
Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Generating text preview…