Synopses & Reviews
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
Synopsis
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 offers many different kinds of streams, each with its ownapplication."Java I/O tells you all you need to know about the four maincategories of streams and uncovers less-known features to help makeyour I/O operations more efficient. You'll find detailed coverage of input and output streams for reading and writing binary data, and readers and writers for reading and writing textual (character) data. You'll then learn about the more elusive CryptInputStream for readingencrypted data and the ZipOutputStream for automatically compressingdata, plus how to effectively use buffered streams. Java is the first programming language that lets you do I/O invirtually any language. It also provides a sophisticated model forformatting textual and numeric data. "Java I/O shows you howto control number formatting, use characters aside from the standard(but outdated) ASCII character set, and get a head start on writingtruly multilingual software.
Synopsis
Intermediate programmers can refer to this guide to gain a solid understanding of text formatting in an object-oriented language. "Java I/O" explores streams, which provide simple ways to read and write data of different types, and 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 multi-lingual software.
About 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 Prospect Heights neighborhood of Brooklyn with his wife Beth and dog Thor. He's a frequent speaker at industry conferences including Software Development, Dr. Dobb's Architecture & 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.
Table of Contents
Dedication; Preface; Correcting Misconceptions; Organization of the Book; Who You Are; Versions; Security Issues; Conventions Used in This Book; Request for Comments; Acknowledgments; 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 The Ubiquitous IOException; 1.6 The Console: System.out, System.in, and System.err; 1.7 Security Checks on I/O; Chapter 2: Output Streams; 2.1 The OutputStream Class; 2.2 Writing Bytes to Output Streams; 2.3 Writing Arrays of Bytes; 2.4 Flushing and Closing Output Streams; 2.5 Subclassing OutputStream; 2.6 A Graphical User Interface for Output Streams; Chapter 3: Input Streams; 3.1 The InputStream Class; 3.2 The read( ) Method; 3.3 Reading Chunks of Data from a Stream; 3.4 Counting the Available Bytes; 3.5 Skipping Bytes; 3.6 Closing Input Streams; 3.7 Marking and Resetting; 3.8 Subclassing InputStream; 3.9 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 Print Streams; 6.6 Multitarget Output Streams; 6.7 File Viewer, Part 2; Chapter 7: Data Streams; 7.1 The Data Stream Classes; 7.2 Reading and Writing Integers; 7.3 Reading and Writing Floating-Point Numbers; 7.4 Reading and Writing Booleans; 7.5 Reading Byte Arrays; 7.6 Reading and Writing Text; 7.7 Miscellaneous Methods; 7.8 Reading and Writing Little-Endian Numbers; 7.9 Thread Safety; 7.10 File Viewer, Part 3; Chapter 8: Streams in Memory; 8.1 Sequence Input Streams; 8.2 Byte Array Streams; 8.3 Communicating Between Threads with Piped Streams; Chapter 9: Compressing Streams; 9.1 Inflaters and Deflaters; 9.2 Compressing and Decompressing Streams; 9.3 Working with Zip Files; 9.4 Checksums; 9.5 JAR Files; 9.6 File Viewer, Part 4; Chapter 10: Cryptographic Streams; 10.1 Hash Function Basics; 10.2 The MessageDigest Class; 10.3 Digest Streams; 10.4 Encryption Basics; 10.5 The Cipher Class; 10.6 Cipher Streams; 10.7 File Viewer, Part 5; Advanced and Miscellaneous Topics; Chapter 11: Object Serialization; 11.1 Reading and Writing Objects; 11.2 Object Streams; 11.3 How Object Serialization Works; 11.4 Performance; 11.5 The Serializable Interface; 11.6 The ObjectInput and ObjectOutput Interfaces; 11.7 Versioning; 11.8 Customizing the Serialization Format; 11.9 Resolving Classes; 11.10 Resolving Objects; 11.11 Validation; 11.12 Sealed Objects; Chapter 12: Working with Files; 12.1 Understanding Files; 12.2 Directories and Paths; 12.3 The File Class; 12.4 Filename Filters; 12.5 File Filters; 12.6 File Descriptors; 12.7 Random-Access Files; 12.8 General Techniques for Cross-Platform File Access Code; Chapter 13: File Dialogs and Choosers; 13.1 File Dialogs; 13.2 JFileChooser; 13.3 File Viewer, Part 6; Chapter 14: Multilingual Character Sets and Unicode; 14.1 Unicode; 14.2 Displaying Unicode Text; 14.3 Unicode Escapes; 14.4 UTF-8; 14.5 The char Data Type; 14.6 Other Encodings; 14.7 Converting Between Byte Arrays and Strings; Chapter 15: Readers and Writers; 15.1 The java.io.Writer Class; 15.2 The OutputStreamWriter Class; 15.3 The java.io.Reader Class; 15.4 The InputStreamReader Class; 15.5 Character Array Readers and Writers; 15.6 String Readers and Writers; 15.7 Reading and Writing Files; 15.8 Buffered Readers and Writers; 15.9 Print Writers; 15.10 Piped Readers and Writers; 15.11 Filtered Readers and Writers; 15.12 File Viewer Finis; Chapter 16: Formatted I/O with java.text; 16.1 The Old Way; 16.2 Choosing a Locale; 16.3 Number Formats; 16.4 Specifying Width with FieldPosition; 16.5 Parsing Input; 16.6 Decimal Formats; 16.7 An Exponential Number Format; Chapter 17: The Java Communications API; 17.1 The Architecture of the Java Communications API; 17.2 Identifying Ports; 17.3 Communicating with a Device on a Port; 17.4 Serial Ports; 17.5 Parallel Ports; Appendixes; Additional Resources; Digital Think; Design Patterns; The java.io Package; Network Programming; Data Compression; Encryption and Related Technology; Object Serialization; International Character Sets and Unicode; Java Communications API; Updates and Breaking News; Character Sets; Colophon;