Please consider the latest edition.
-
Chapter 1 Getting Started: Compiling, Running, and Debugging
-
Introduction
-
Compiling and Running Java: JDK
-
Editing and Compiling with a Color-Highlighting Editor
-
Compiling, Running, and Testing with an IDE
-
Using Classes from This Book
-
Automating Compilation with jr
-
Automating Compilation with make
-
Automating Compilation with Ant
-
Running Applets
-
Dealing with Deprecation Warnings
-
Conditional Debugging without #ifdef
-
Debugging Printouts
-
Using a Debugger
-
Unit Testing: Avoid the Need for Debuggers
-
Decompiling Java Class Files
-
Preventing Others from Decompiling Your Java Files
-
Getting Readable Tracebacks
-
Finding More Java Source Code
-
Program: Debug
-
-
Chapter 2 Interacting with the Environment
-
Introduction
-
Getting Environment Variables
-
System Properties
-
Writing JDK Release-Dependent Code
-
Writing Operating System-Dependent Code
-
Using CLASSPATH Effectively
-
Using Extensions or Other Packaged APIs
-
Parsing Command-Line Arguments
-
-
Chapter 3 Strings and Things
-
Introduction
-
Taking Strings Apart with Substrings
-
Taking Strings Apart with StringTokenizer
-
Putting Strings Together with + and StringBuffer
-
Processing a String One Character at a Time
-
Aligning Strings
-
Converting Between Unicode Characters and Strings
-
Reversing a String by Word or Character
-
Expanding and Compressing Tabs
-
Controlling Case
-
Indenting Text Documents
-
Entering Non-Printable Characters
-
Trimming Blanks from the End of a String
-
Parsing Comma-Separated Data
-
Program: A Simple Text Formatter
-
Program: Soundex Name Comparisons
-
-
Chapter 4 Pattern Matching with Regular Expressions
-
Introduction
-
Regular Expression Syntax
-
How REs Work in Practice
-
Using Regular Expressions in Java
-
Testing REs Interactively
-
Finding the Matching Text
-
Replacing the Matching Text
-
Printing All Occurrences of a Pattern
-
Printing Lines Containing a Pattern
-
Controlling Case in match( ) and subst( )
-
Precompiling the RE
-
Matching Newlines in Text
-
Program: Data Mining
-
Program: Full Grep
-
-
Chapter 5 Numbers
-
Introduction
-
Checking Whether a String Is a Valid Number
-
Storing a Larger Number in a Smaller
-
Taking a Fraction of an Integer Without Using Floating Point
-
Ensuring the Accuracy of Floating-Point Numbers
-
Comparing Floating-Point Numbers
-
Rounding Floating-Point Numbers
-
Formatting Numbers
-
Converting Between Binary, Octal, Decimal, and Hexadecimal
-
Operating on a Series of Integers
-
Working with Roman Numerals
-
Formatting with Correct Plurals
-
Generating Random Numbers
-
Generating Better Random Numbers
-
Calculating Trigonometric Functions
-
Taking Logarithms
-
Multiplying Matrixes
-
Using Complex Numbers
-
Handling Very Large Numbers
-
Program: TempConverter
-
Program: Number Palindromes
-
-
Chapter 6 Dates and Times
-
Introduction
-
Finding Today's Date
-
Printing Date/Time in a Specified Format
-
Representing Dates in Other Epochs
-
Converting YMDHMS to a Calendar or Epoch Seconds
-
Parsing Strings into Dates
-
Converting Epoch Seconds to DMYHMS
-
Adding to or Subtracting from a Date or Calendar
-
Difference Between Two Dates
-
Comparing Dates
-
Day of Week/Month/Year or Week Number
-
Calendar Page
-
High-Resolution Timers
-
Sleeping for a While
-
Program: Reminder Service
-
-
Chapter 7 Structuring Data with Java
-
Introduction
-
Data Structuring Using Arrays
-
Resizing an Array
-
Like an Array, but More Dynamic
-
Data-Independent Access with Iterators
-
Structuring Data in a Linked List
-
Mapping with Hashtable and HashMap
-
Storing Strings in Properties and Preferences
-
Sorting a Collection
-
Sorting in Java 1.1
-
Avoiding the Urge to Sort
-
Sets
-
Finding an Object in a Collection
-
Converting a Collection to an Array
-
Rolling Your Own Iterator
-
Stack
-
Multidimensional Structures
-
Finally, Collections
-
Program: Timing Comparisons
-
-
Chapter 8 Object-Oriented Techniques
-
Introduction
-
Printing Objects: Formatting with toString( )
-
Overriding the Equals Method
-
Overriding the Hashcode Method
-
The Clone Method
-
The Finalize Method
-
Using Inner Classes
-
Providing Callbacks via Interfaces
-
Polymorphism/Abstract Methods
-
Passing Values
-
Roll Your Own Exceptions
-
Program: Plotter
-
-
Chapter 9 Input and Output
-
Introduction
-
Reading Standard Input
-
Writing Standard Output
-
Opening a File by Name
-
Copying a File
-
Reading a File into a String
-
Reassigning the Standard Streams
-
Duplicating a Stream as It Is Written
-
Reading/Writing a Different Character Set
-
Those Pesky End-of-Line Characters
-
Beware Platform-Dependent File Code
-
Reading "Continued" Lines
-
Scanning a File
-
Binary Data
-
Seeking
-
Writing Data Streams from C
-
Saving and Restoring Serialized Objects
-
Preventing ClassCastExceptions with SerialVersionUID
-
Reading and Writing JAR or Zip Archives
-
Reading and Writing Compressed Files
-
Program: Text to PostScript
-
Program: TarList (File Converter)
-
-
Chapter 10 Directory and Filesystem Operations
-
Introduction
-
Getting File Information
-
Creating a File
-
Renaming a File
-
Deleting a File
-
Creating a Transient File
-
Changing File Attributes
-
Listing a Directory
-
Getting the Directory Roots
-
Making New Directories
-
Program: Find
-
-
Chapter 11 Programming Serial and Parallel Ports
-
Introduction
-
Choosing a Port
-
Opening a Serial Port
-
Opening a Parallel Port
-
Resolving Port Conflicts
-
Reading and Writing: Lock Step
-
Reading and Writing: Event-Driven
-
Reading and Writing: Threads
-
Program: Penman Plotter
-
-
Chapter 12 Graphics and Sound
-
Introduction
-
Painting with a Graphics Object
-
Testing Graphical Components
-
Drawing Text
-
Drawing Centered Text in a Component
-
Drawing a Drop Shadow
-
Drawing an Image
-
Playing a Sound File
-
Displaying a Moving Image with Video
-
Drawing Text with 2D
-
Printing: JDK 1.1
-
Printing: Java 2
-
Program: PlotterAWT
-
Program: Grapher
-
-
Chapter 13 Graphical User Interfaces
-
Introduction
-
Displaying GUI Components
-
Designing a Window Layout
-
A Tabbed View of Life
-
Action Handling: Making Buttons Work
-
Action Handling Using Anonymous Inner Classes
-
Terminating a Program with "Window Close"
-
Dialogs: When Later Just Won't Do
-
Getting Program Output into a Window
-
Choosing a File with JFileChooser
-
Choosing a Color
-
Centering a Main Window
-
Changing a Swing Program's Look and Feel
-
Program: Custom Font Chooser
-
Program: Custom Layout Manager
-
-
Chapter 14 Internationalization and Localization
-
Introduction
-
Creating a Button with I18N Resources
-
Listing Available Locales
-
Creating a Menu with I18N Resources
-
Writing Internationalization Convenience Routines
-
Creating a Dialog with I18N Resources
-
Creating a Resource Bundle
-
JILTing Your Code
-
Using a Particular Locale
-
Setting the Default Locale
-
Formatting Messages
-
Program: MenuIntl
-
Program: BusCard
-
-
Chapter 15 Network Clients
-
Introduction
-
Contacting a Server
-
Finding and Reporting Network Addresses
-
Handling Network Errors
-
Reading and Writing Textual Data
-
Reading and Writing Binary Data
-
Reading and Writing Serialized Data
-
UDP Datagrams
-
Program: TFTP UDP Client
-
Program: Telnet Client
-
Program: Chat Client
-
-
Chapter 16 Server-Side Java: Sockets
-
Introduction
-
Opening a Server for Business
-
Returning a Response (String or Binary)
-
Returning Object Information
-
Handling Multiple Clients
-
Network Logging
-
Program: A Java Chat Server
-
-
Chapter 17 Network Clients II: Applets and Web Clients
-
Introduction
-
Embedding Java in a Web Page
-
Applet Techniques
-
Contacting a Server on the Applet Host
-
Making an Applet Show a Document
-
Making an Applet Run a CGI Script
-
Reading the Contents of a URL
-
Extracting HTML from a URL
-
Extracting URLs from a File
-
Converting a Filename to a URL
-
Program: MkIndex
-
Program: LinkChecker
-
-
Chapter 18 Web Server Java: Servlets and JSP
-
Introduction
-
First Servlet: Generating an HTML Page
-
Servlets: Processing Form Parameters
-
Cookies
-
Session Tracking
-
Generating PDF from a Servlet
-
HTML Meets Java: JSP
-
JSP Include/Forward
-
JavaServer Pages Using a Servlet
-
Simplifying Your JSP with a JavaBean
-
JSP Syntax Summary
-
Program: CookieCutter
-
Program: JabaDot Web News Portal
-
-
Chapter 19 Java and Electronic Mail
-
Introduction
-
Sending Email: Browser Version
-
Sending Email: For Real
-
Mail-Enabling a Server Program
-
Sending MIME Mail
-
Providing Mail Settings
-
Sending Mail Without Using JavaMail
-
Reading Email
-
Program: MailReaderBean
-
Program: MailClient
-
-
Chapter 20 Database Access
-
Introduction
-
Text-File Databases
-
DBM Databases
-
JDBC Setup and Connection
-
Connecting to a JDBC Database
-
Sending a JDBC Query and Getting Results
-
Using JDBC Parameterized Statements
-
Using Stored Procedures with JDBC
-
Changing Data Using a ResultSet
-
Changing Data Using SQL
-
Finding JDBC Metadata
-
Program: JDAdmin
-
-
Chapter 21 XML
-
Introduction
-
Transforming XML with XSLT
-
Parsing XML with SAX
-
Parsing XML with DOM
-
Verifying Structure with a DTD
-
Generating Your Own XML with DOM
-
Program: xml2mif
-
-
Chapter 22 Distributed Java: RMI
-
Introduction
-
Defining the RMI Contract
-
RMI Client
-
RMI Server
-
Deploying RMI Across a Network
-
Program: RMI Callbacks
-
Program: RMIWatch
-
-
Chapter 23 Packages and Packaging
-
Introduction
-
Creating a Package
-
Documenting Classes with Javadoc
-
Archiving with jar
-
Running an Applet from a JAR
-
Running an Applet with a JDK
-
Running a Program from a JAR
-
Preparing a Class as a JavaBean
-
Pickling Your Bean into a JAR
-
Packaging a Servlet into a WAR File
-
"Write Once, Install Anywhere"
-
Java Web Start
-
Signing Your JAR File
-
-
Chapter 24 Threaded Java
-
Introduction
-
Running Code in a Different Thread
-
Displaying a Moving Image with Animation
-
Stopping a Thread
-
Rendezvous and Timeouts
-
Thread Communication: Synchronized Code
-
Thread Communication: wait( ) and notifyAll( )
-
Background Saving in an Editor
-
Threaded Network Server
-
-
Chapter 25 Introspection, or "A Class Named Class"
-
Introduction
-
Getting a Class Descriptor
-
Finding and Using Methods and Fields
-
Loading and Instantiating a Class Dynamically
-
Constructing a Class from Scratch
-
Performance Timing
-
Printing Class Information
-
Program: CrossRef
-
Program: AppletViewer
-
-
Chapter 26 Using Java with Other Languages
-
Introduction
-
Running a Program
-
Running a Program and Capturing Its Output
-
Mixing Java and Scripts with BSF
-
Blending in Native Code (C/C++)
-
Calling Java from Native Code
-
Program: DBM
-
-
Chapter 27 Afterword
-
Colophon
- Title:
- Java Cookbook
- By:
- Ian F. Darwin
- Publisher:
- O'Reilly Media
- Formats:
-
- Safari Books Online
- Print Release:
- June 2001
- Pages:
- 888
- Print ISBN:
- 978-0-596-00170-4
- | ISBN 10:
- 0-596-00170-3
Our look is the result of reader comments, our own experimentation, and feedback from distribution channels. Distinctive covers complement our distinctive approach to technical topics, breathing personality and life into potentially dry subjects. The animal on the cover of Java Cookbook is a domestic chicken. Domestic chickens (Gallus gallus) are descended from the wild red jungle fowl of India. Domesticated over 8,000 years ago in the area that is now Vietnam and Thailand, chickens are raised for meat and eggs, and the males for sport as well (though cockfighting is currently against the law in many places).
With their big, heavy bodies and small wings, these birds are well suited to living on the ground, and they can fly at most only short distances. Their four-toed feet are designed for scratching in the dirt, where they find the elements of their usual diet: worms, bugs, seeds, and various plant matter.
A male chicken is called a rooster or cock, and a female is known as a hen. The incubation period for a chicken egg is about three weeks; newly hatched chickens are precocial, meaning they have downy feathers and can walk around on their own right after emerging from the egg. They're also not dependent on their mothers for food; not only can they procure their own, but they also can live for up to a week post-hatch on egg yolk that remains in their abdomen after birth.
The topic of chickens comes up frequently in ancient writings. Chinese documents date their introduction to China to 1400 B.C., Babylonian carvings mention them in 600 B.C., and Aristophanes wrote about them in 400 B.C. The rooster has long symbolized courage: the Romans thought chickens were sacred to Mars, god of war, and the first French Republic chose the rooster as its emblem. Emily Quill was the production editor and copyeditor for Java Cookbook. Claire Cloutier, Colleen Gorman, and Jane Ellin conducted quality control reviews, and Edith Shapiro, Sada Preisch, Lucy Muellner, Linley Dolby, and Matt Hutchinson provided production assistance. Ellen Troutman-Zaig wrote the index.
Hanna Dyer designed the cover of this book, based on a series design by Edie Freedman. The cover image is a 19th-century engraving from the Dover Pictoral Archive. Emma Colby produced the cover layout with QuarkXPress 4.1 using Adobe's ITC Garamond font.
Melanie Wang and David Futato designed the interior layout, based on a series design by Nancy Priest. Mike Sierra implemented the design in FrameMaker 5.5.6. The heading font is Bitstream Bodoni, the text font is ITC New Baskerville, and the code font is Constant Willison. The illustrations that appear in the book were produced by Robert Romano and Jessamyn Read using Macromedia FreeHand 9 and Adobe Photoshop 6. This colophon was written by Leanne Soylemez.
