Home Page Icon
Home Page
Table of Contents for
V. Appendixes
Close
V. Appendixes
by Elliotte Rusty Harold
Java I/O
Java I/O
Dedication
Preface
Correcting Misconceptions
Organization of the Book
Part I: Basic I/O
Part II: Data Sources
Part III: Filter Streams
Part IV: Advanced and Miscellaneous Topics
Who You Are
Versions
Security Issues
Conventions Used in This Book
Request for Comments
Acknowledgments
I. Basic I/O
1. Introducing I/O
What Is a Stream?
Where Do Streams Come From?
The Stream Classes
Numeric Data
Integer Data
Conversions and Casts
Character Data
ASCII
ISO Latin-1
Unicode
UTF-8
Other encodings
The char Data Type
Readers and Writers
The Ubiquitous IOException
The Console: System.out, System.in, and System.err
Consoles in Applets
System.out
System.err
System.in
Redirecting System.out, System.in, and System.err
Security Checks on I/O
2. Output Streams
The OutputStream Class
Writing Bytes to Output Streams
Writing Arrays of Bytes
Flushing and Closing Output Streams
Subclassing OutputStream
A Graphical User Interface for Output Streams
3. Input Streams
The InputStream Class
The read( ) Method
Reading Chunks of Data from a Stream
Counting the Available Bytes
Skipping Bytes
Closing Input Streams
Marking and Resetting
Subclassing InputStream
An Efficient Stream Copier
II. Data Sources
4. File Streams
Reading Files
Writing Files
File Viewer, Part 1
5. Network Streams
URLs
URL Connections
Reading Data from URL Connections
Writing Data on URL Connections
Sockets
Server Sockets
URLViewer
III. Filter Streams
6. Filter Streams
The Filter Stream Classes
The Filter Stream Subclasses
Buffered Streams
BufferedInputStream Details
BufferedOutputStream Details
PushbackInputStream
Print Streams
Multitarget Output Streams
File Viewer, Part 2
7. Data Streams
The Data Stream Classes
The DataInput and DataOutput Interfaces
Constructors
Reading and Writing Integers
Integer Formats
The Char Format
Writing Integers
Reading Integers
Reading and Writing Floating-Point Numbers
Writing Floating-Point Numbers
Reading Floating-Point Numbers
Reading and Writing Booleans
Reading Byte Arrays
Reading and Writing Text
The UTF-8 Format
Writing Text
Reading Text
The Deprecated readLine( ) Method
Miscellaneous Methods
Determining the Number of Bytes Written
Skipping Bytes in an Input Stream
Reading and Writing Little-Endian Numbers
Thread Safety
File Viewer, Part 3
8. Streams in Memory
Sequence Input Streams
Byte Array Streams
Byte Array Input Streams
Byte Array Output Streams
Communicating Between Threads with Piped Streams
9. Compressing Streams
Inflaters and Deflaters
Deflating Data
Constructing deflaters
Choose a strategy
Set the compression level
Set the dictionary
Set the input
Deflate the data repeatedly until needsInput( ) returns true
Finish the deflation
Reset the deflater and start over
An example
Checking the state of a deflater
Inflating Data
Constructing inflaters
Set the input
Check whether a preset dictionary was used
Set the dictionary
Inflate the data
Reset the inflater
An example
Checking the state of an inflater
Compressing and Decompressing Streams
The DeflaterOutputStream Class
The InflaterInputStream Class
The GZIPOutputStream Class
The GZIPInputStream Class
Expanding Output Streams and Compressing Input Streams
Working with Zip Files
Zip Entries
The ZipOutputStream Class
Constructing and initializing the ZipOutputStream
Set the comment for the zip file
Set the default compression level and method
Construct a ZipEntry object and put it in the archive
Write the entry’s data onto the output stream
Close the zip entry
Finish the zip output stream
Close the zip output stream
An example
The ZipInputStream Class
Construct a ZipInputStream
Open the next zip entry
Reading from a ZipInputStream
Close the zip entry
Close the ZipInputStream
An example
Checksums
Checked Streams
JAR Files
Meta-Infomation: Manifest Files and Signatures
The jar Tool
The java.util.jar Package
JarFile
JarEntry
Attributes
Manifest
JarInputStream
JarOutputStream
JarURLConnection
File Viewer, Part 4
10. Cryptographic Streams
Hash Function Basics
Requirements for Hash Functions
The MessageDigest Class
Calculating Message Digests
Creating Message Digests
Feeding Data to the Digest
Finishing the Digest
Reusing Digests
Comparing Digests
Accessor Methods
Cloning Digests
toString( )
Digest Streams
DigestInputStream
DigestOutputStream
Encryption Basics
Keys
Secret Key Versus Public Key Algorithms
Block Versus Stream Ciphers
Key Management
The Cipher Class
init( )
Mode
Key
Algorithm parameters
Source of randomness
update( )
doFinal( )
Accessor Methods
Cipher Streams
CipherInputStream
CipherOutputStream
File Viewer, Part 5
IV. Advanced and Miscellaneous Topics
11. Object Serialization
Reading and Writing Objects
Object Streams
How Object Serialization Works
Performance
The Serializable Interface
Classes That Implement Serializable but Aren’t
Problem 1: References to nonserializable objects
Problem 2: Missing a no-argument constructor in superclass
Problem 3: Deliberate throwing of NotSerializableException
Locating the offending object
Making nonserializable fields transient
The ObjectInput and ObjectOutput Interfaces
Versioning
Compatible and Incompatible Changes
Version IDs
Customizing the Serialization Format
The readObject( ) and writeObject( ) Methods
The default WriteObject( ) and defaultReadObject( ) Methods
Preventing Serialization
Externalizable
Resolving Classes
Resolving Objects
Validation
Sealed Objects
12. Working with Files
Understanding Files
Filenames
File Attributes
Filename Extensions and File Types
Directories and Paths
Paths and Separators
Relative Versus Absolute Paths
Absolute paths
Relative paths
The File Class
Constructing File Objects
Listing the Roots
Listing Information About a File
Does the file exist? Is it a normal file? Is it a directory?
Filename and path
Absolute paths
Canonical paths
Parents
File attributes
An example
Manipulating Files
Creating files
Moving and renaming files
Copying files
Deleting files
Changing file attributes
Temporary Files
Utility Methods
Working with Directories
Creating directories
Listing directories
The listFiles() methods
File URLs
Filename Filters
File Filters
File Descriptors
Random-Access Files
General Techniques for Cross-Platform File Access Code
13. File Dialogs and Choosers
File Dialogs
JFileChooser
Constructing File Choosers
Displaying File Choosers
Getting the User’s Selection
Programmatically Manipulating the JFileChooser
Custom Dialogs
Filters
Selecting Directories
Multiple Selections
Hidden Files
File Views
Filesystem Views
Handling Events
Action events
Property change events
Accessory
Swing Methods
File Viewer, Part 6
14. Multilingual Character Sets and Unicode
Unicode
Displaying Unicode Text
Unicode Escapes
UTF-8
The char Data Type
The java.lang.Character Class
Constructor
Instance methods
Character types
Identifiers
Numeric values
Character subsets
Unicode blocks
Other Encodings
Converting Between Byte Arrays and Strings
15. Readers and Writers
The java.io.Writer Class
The OutputStreamWriter Class
The java.io.Reader Class
The InputStreamReader Class
Character Array Readers and Writers
The CharArrayWriter Class
The CharArrayReader Class
String Readers and Writers
String Writers
String Readers
Reading and Writing Files
FileWriter
FileReader
Buffered Readers and Writers
Buffering Writes for Better Performance
Buffering Reads for Better Performance
Line Numbering
Print Writers
Piped Readers and Writers
Filtered Readers and Writers
The FilterReader Class
The FilterWriter Class
PushbackReader
File Viewer Finis
16. Formatted I/O with java.text
The Old Way
Choosing a Locale
Number Formats
Formatting Numbers
Specifying Precision
Grouping
Currency Formats
Percent Formats
Utility Methods
Specifying Width with FieldPosition
Parsing Input
Decimal Formats
Decimal Format Patterns and Symbols
DecimalFormatSymbols
Utility methods
Constructing Decimal Formats with Patterns and Symbols
An Exponential Number Format
17. The Java Communications API
The Architecture of the Java Communications API
Identifying Ports
Finding the Ports
Getting Information About a Port
Opening Ports
Waiting for a Port with Port Ownership Events
Registering Ports
Communicating with a Device on a Port
Communicating with a Port
Port Properties
Serial Ports
Control Functions
Flow Control
Control Wires
DTR
RTS
CTS
DSR
RI
CD
Serial Port Events
Serial Port Event Listeners
Step 1
Step 2
Step 3
Parallel Ports
Parallel Port Modes
Controlling the Parallel Port
Checking the State of the Port
Parallel Port Events
Parallel Port Event Listeners
Step 1
Step 2
Step 3
V. Appendixes
A. 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
Café au Lait
java.oreilly.com
JavaWorld
B. Character Sets
Index
Colophon
Search in book...
Toggle Font Controls
Playlists
Add To
Create new playlist
Name your new playlist
Playlist description (optional)
Cancel
Create playlist
Sign In
Email address
Password
Forgot Password?
Create account
Login
or
Continue with Facebook
Continue with Google
Sign Up
Full Name
Email address
Confirm Email Address
Password
Login
Create account
or
Continue with Facebook
Continue with Google
Prev
Previous Chapter
Parallel Ports
Next
Next Chapter
A. Additional Resources
Part V. Appendixes
Add Highlight
No Comment
..................Content has been hidden....................
You can't read the all page of ebook, please click
here
login for view all page.
Day Mode
Cloud Mode
Night Mode
Reset