Statistics
Registered Users: 1016 Java SE Tips: 614 Java ME Tips: 201 Java EE Tips: 184 Other API Tips: 779 Java Applications: 298 Java Libraries: 209 Java Games: 16 Book Reviews:
Java Cookbook - Second Edition
Book Information
Authors:
Ian Darwin
Paperback: 862 pages
Publisher: O'Reilly Media, Inc.; 2 edition (June 14, 2004)
Language: English
ISBN: 0596007019
Product Dimensions: 9.2 x 7.1 x 1.5 inches
Amazon.com Link
Book Review
The Java Cookbook from O’reilly publishers is a book with around 312 ready made recipes that are baked well to suit your day to day needs in various aspects of Java programming.
Purpose
Most of the textbooks out in the market take you half way in the journey of any technology. This is the main reason that most of us opt for online articles on particular topics instead of buying advanced titles. We just don’t get what we expect from an advanced book-“How can I implement this in Java?” and this is the book that is an exception. It is definitely many steps ahead of any other Java book. The author Ian F. Darwin has managed to come up with not only cooked recipe concepts but has also given over 37 excellent program recipes that ranges from utilities like ‘Text to PostScript’, ‘Penman Plotter’ to something comparatively small like a Text Formatter or a Number Palindrome.
Organization
The book divides the recipes into 26 chapters based on the concept they rely upon. The first seven chapters cover mostly simple, but very useful recipes like working with Dates and Time, working with Collections, Arraylists, etc. In all there are around 102 fundamental recipes. They are not necessarily fundamental, but anyone with little knowledge of the programming language can use them with ease. The eighth chapter is dedicated to recipes on “JDK 5-only” concepts like Enumerations, Generics and foreach loops. The ninth chapter is dedicated for object oriented techniques and 11 cool recipes have been presented here.
The next three chapters, 10th, 11th and 12th deals with the aspects of input and output. Chapter 10 deals with file handling while the 11th chapter is a bit more on the advanced features of file handling and also shows how to work with directories. The 13th chapter is the most interesting one and it shows how to read and write on Ports, I mean hardware ports. If you happen to visit any Java forum, there shall definitely be a topic on “how do I connect to parallel port in Java?” and this is the book that they should all look out for. Not only that question, there are many other regular questions that the book answers in a fine manner.
Graphics and Sound related recipes are in the 14th chapter and the next two chapters are on developing GUI applications and Internationalization concepts. The three chapters from here give 35 recipes on Network Programming in Java. The other chapters include recipes on Database Access, Java and Email, Distributed Programming using RMI, Threading concepts, etc. The final chapter consists of recipes to connect to other programs through Java, though not covered completely, but it does give a good start to those who are looking for some basic answers.
Difference
Reading the above review, a few might get scared thinking this book has all advanced topics and is of no use to any beginner, then that would be a big mistake. The book though targets a somewhat advanced programmer but the nature of cookbook really helps even the beginners. As a beginner to whom the world of Java is unknown, you shall get the chance to know the power of Java and what you can achieve through Java. You have around 250+ programs at your disposal to play with and thus help you to learn by example. But as a bare minimum, you should be acquainted with basics of Java. Most of the recipes are followed by a “See Also” section which as a matter of fact proves very useful. It tells the reader, where extra information regarding the concept could be found. Thus, in case you end with half baked recipe, which doesn’t happen in most of the situations, you know the place to search. Those experienced, though doesn’t need an advice on “how to use this book”, they can use it as a reference, a collection of excellent code and startups.
Finally
Overall, this book is another masterpiece from O’reilly publishers and is a serious book, a “no nonsense” collection of really tasty recipes. It is a must-have in a serious Java developer library.
Table of Contents
Chapter 1. Getting Started: Compiling, Running, and Debugging
Introduction
Section 1.1. Compiling and Running Java: JDK
Section 1.2. Editing and Compiling with a Color-Highlighting Editor
Section 1.3. Compiling, Running, and Testing with an IDE
Section 1.4. Using CLASSPATH Effectively
Section 1.5. Using the com.darwinsys API Classes from This Book
Section 1.6. Compiling the Source Code Examples from This Book
Section 1.7. Automating Compilation with Ant
Section 1.8. Running Applets
Section 1.9. Dealing with Deprecation Warnings
Section 1.10. Conditional Debugging Without #ifdef
Section 1.11. Debugging Printouts
Section 1.12. Maintaining Program Correctness with Assertions
Section 1.13. Debugging with JDB
Section 1.14. Unit Testing: Avoid the Need for Debuggers
Section 1.15. Getting Readable Tracebacks
Section 1.16. Finding More Java Source Code
Section 1.17. Program: Debug
Chapter 2. Interacting with the Environment
Introduction
Section 2.1. Getting Environment Variables
Section 2.2. System Properties
Section 2.3. Writing JDK Release-Dependent Code
Section 2.4. Writing Operating System-Dependent Code
Section 2.5. Using Extensions or Other Packaged APIs
Section 2.6. Parsing Command-Line Arguments
Chapter 3. Strings and Things
Introduction
Section 3.1. Taking Strings Apart with Substrings
Section 3.2. Taking Strings Apart with StringTokenizer
Section 3.3. Putting Strings Together with +, StringBuilder and StringBuffer
Section 3.4. Processing a String One Character at a Time
Section 3.5. Aligning Strings
Section 3.6. Converting Between Unicode Characters and Strings
Section 3.7. Reversing a String by Word or by Character
Section 3.8. Expanding and Compressing Tabs
Section 3.9. Controlling Case
Section 3.10. Indenting Text Documents
Section 3.11. Entering Nonprintable Characters
Section 3.12. Trimming Blanks from the End of a String
Section 3.13. Parsing Comma-Separated Data
Section 3.14. Program: A Simple Text Formatter
Section 3.15. Program: Soundex Name Comparisons
Chapter 4. Pattern Matching with Regular Expressions
Introduction
Section 4.1. Regular Expression Syntax
Section 4.2. Using regexes in Java: Test for a Pattern
Section 4.3. Finding the Matching Text
Section 4.4. Replacing the Matched Text
Section 4.5. Printing All Occurrences of a Pattern
Section 4.6. Printing Lines Containing a Pattern
Section 4.7. Controlling Case in Regular Expressions
Section 4.8. Matching "Accented" or Composite Characters
Section 4.9. Matching Newlines in Text
Section 4.10. Program: Apache Logfile Parsing
Section 4.11. Program: Data Mining
Section 4.12. Program: Full Grep
Chapter 5. Numbers
Introduction
Section 5.1. Checking Whether a String Is a Valid Number
Section 5.2. Storing a Larger Number in a Smaller Number
Section 5.3. Converting Numbers to Objects and Vice Versa
Section 5.4. Taking a Fraction of an Integer Without Using Floating Point
Section 5.5. Ensuring the Accuracy of Floating-Point Numbers
Section 5.6. Comparing Floating-Point Numbers
Section 5.7. Rounding Floating-Point Numbers
Section 5.8. Formatting Numbers
Section 5.9. Converting Between Binary, Octal, Decimal, and Hexadecimal
Section 5.10. Operating on a Series of Integers
Section 5.11. Working with Roman Numerals
Section 5.12. Formatting with Correct Plurals
Section 5.13. Generating Random Numbers
Section 5.14. Generating Better Random Numbers
Section 5.15. Calculating Trigonometric Functions
Section 5.16. Taking Logarithms
Section 5.17. Multiplying Matrices
Section 5.18. Using Complex Numbers
Section 5.19. Handling Very Large Numbers
Section 5.20. Program: TempConverter
Section 5.21. Program: Number Palindromes
Chapter 6. Dates and Times
Introduction
Section 6.1. Finding Today's Date
Section 6.2. Printing Date/Time in a Given Format
Section 6.3. Representing Dates in Other Epochs
Section 6.4. Converting YMDHMS to a Calendar or Epoch Seconds
Section 6.5. Parsing Strings into Dates
Section 6.6. Converting Epoch Seconds to DMYHMS
Section 6.7. Adding to or Subtracting from a Date or Calendar
Section 6.8. Difference between Two Dates
Section 6.9. Comparing Dates
Section 6.10. Day of Week/Month/Year or Week Number
Section 6.11. Creating a Calendar Page
Section 6.12. Measuring Elapsed Time
Section 6.13. Sleeping for a While
Section 6.14. Program: Reminder Service
Chapter 7. Structuring Data with Java
Introduction
Section 7.1. Using Arrays for Data Structuring
Section 7.2. Resizing an Array
Section 7.3. Like an Array, but More Dynamic
Section 7.4. Using Iterators for Data-Independent Access
Section 7.5. Structuring Data in a Linked List
Section 7.6. Mapping with Hashtable and HashMap
Section 7.7. Storing Strings in Properties and Preferences
Section 7.8. Sorting a Collection
Section 7.9. Avoiding the Urge to Sort
Section 7.10. Eschewing Duplication
Section 7.11. Finding an Object in a Collection
Section 7.12. Converting a Collection to an Array
Section 7.13. Rolling Your Own Iterator
Section 7.14. Stack
Section 7.15. Multidimensional Structures
Section 7.16. Finally, Collections
Section 7.17. Program: Timing Comparisons
Chapter 8. Data Structuring with Generics, foreach, and Enumerations (JDK 1.5)
Introduction
Section 8.1. Using Generic Collections
Section 8.2. Using "foreach" Loops
Section 8.3. Avoid Casting by Using Generics
Section 8.4. Let Java Convert with AutoBoxing and AutoUnboxing
Section 8.5. Using Typesafe Enumerations
Section 8.6. Program: MediaInvoicer
Chapter 9. Object-Oriented Techniques
Introduction
Section 9.1. Printing Objects: Formatting with toString( )
Section 9.2. Overriding the Equals Method
Section 9.3. Overriding the hashCode Method
Section 9.4. The Clone Method
Section 9.5. The Finalize Method
Section 9.6. Using Inner Classes
Section 9.7. Providing Callbacks via Interfaces
Section 9.8. Polymorphism/Abstract Methods
Section 9.9. Passing Values
Section 9.10. Enforcing the Singleton Pattern
Section 9.11. Roll Your Own Exceptions
Section 9.12. Program: Plotter
Chapter 10. Input and Output
Introduction
Section 10.1. Reading Standard Input
Section 10.2. Writing Standard Output
Section 10.3. Printing with the 1.5 Formatter
Section 10.4. Scanning a File with StreamTokenizer
Section 10.5. Scanning Input with the 1.5 Scanner Class
Section 10.6. Opening a File by Name
Section 10.7. Copying a File
Section 10.8. Reading a File into a String
Section 10.9. Reassigning the Standard Streams
Section 10.10. Duplicating a Stream as It Is Written
Section 10.11. Reading/Writing a Different Character Set
Section 10.12. Those Pesky End-of-Line Characters
Section 10.13. Beware Platform-Dependent File Code
Section 10.14. Reading "Continued" Lines
Section 10.15. Binary Data
Section 10.16. Seeking
Section 10.17. Writing Data Streams from C
Section 10.18. Saving and Restoring Java Objects
Section 10.19. Preventing ClassCastExceptions with SerialVersionUID
Section 10.20. Reading and Writing JAR or Zip Archives
Section 10.21. Reading and Writing Compressed Files
Section 10.22. Program: Text to PostScript
Chapter 11. Directory and Filesystem Operations
Introduction
Section 11.1. Getting File Information
Section 11.2. Creating a File
Section 11.3. Renaming a File
Section 11.4. Deleting a File
Section 11.5. Creating a Transient File
Section 11.6. Changing File Attributes
Section 11.7. Listing a Directory
Section 11.8. Getting the Directory Roots
Section 11.9. Creating New Directories
Section 11.10. Program: Find
Chapter 12. Programming External Devices: Serial and Parallel Ports
Introduction
Section 12.1. Choosing a Port
Section 12.2. Opening a Serial Port
Section 12.3. Opening a Parallel Port
Section 12.4. Resolving Port Conflicts
Section 12.5. Reading and Writing: Lock-Step
Section 12.6. Reading and Writing: Event-Driven
Section 12.7. Reading and Writing: Threads
Section 12.8. Program: Penman Plotter
Chapter 13. Graphics and Sound
Introduction
Section 13.1. Painting with a Graphics Object
Section 13.2. Testing Graphical Components
Section 13.3. Drawing Text
Section 13.4. Drawing Centered Text in a Component
Section 13.5. Drawing a Drop Shadow
Section 13.6. Drawing Text with 2D
Section 13.7. Drawing Text with an Application Font
Section 13.8. Drawing an Image
Section 13.9. Playing a Sound File
Section 13.10. Playing a Video Clip
Section 13.11. Printing in Java
Section 13.12. Program: PlotterAWT
Section 13.13. Program: Grapher
Chapter 14. Graphical User Interfaces
Introduction
Section 14.1. Displaying GUI Components
Section 14.2. Designing a Window Layout
Section 14.3. A Tabbed View of Life
Section 14.4. Action Handling: Making Buttons Work
Section 14.5. Action Handling Using Anonymous Inner Classes
Section 14.6. Terminating a Program with "Window Close"
Section 14.7. Dialogs: When Later Just Won't Do
Section 14.8. Catching and Formatting GUI Exceptions
Section 14.9. Getting Program Output into a Window
Section 14.10. Choosing a Value with JSpinner
Section 14.11. Choosing a File with JFileChooser
Section 14.12. Choosing a Color
Section 14.13. Formatting JComponents with HTML
Section 14.14. Centering a Main Window
Section 14.15. Changing a Swing Program's Look and Feel
Section 14.16. Enhancing Your GUI for Mac OS X
Section 14.17. Program: Custom Font Chooser
Section 14.18. Program: Custom Layout Manager
Chapter 15. Internationalization and Localization
Introduction
Section 15.1. Creating a Button with I18N Resources
Section 15.2. Listing Available Locales
Section 15.3. Creating a Menu with I18N Resources
Section 15.4. Writing Internationalization Convenience Routines
Section 15.5. Creating a Dialog with I18N Resources
Section 15.6. Creating a Resource Bundle
Section 15.7. Extracting Strings from Your Code
Section 15.8. Using a Particular Locale
Section 15.9. Setting the Default Locale
Section 15.10. Formatting Messages
Section 15.11. Program: MenuIntl
Section 15.12. Program: BusCard
Chapter 16. Network Clients
Introduction
Section 16.1. Contacting a Server
Section 16.2. Finding and Reporting Network Addresses
Section 16.3. Handling Network Errors
Section 16.4. Reading and Writing Textual Data
Section 16.5. Reading and Writing Binary Data
Section 16.6. Reading and Writing Serialized Data
Section 16.7. UDP Datagrams
Section 16.8. Program: TFTP UDP Client
Section 16.9. Program: Telnet Client
Section 16.10. Program: Chat Client
Chapter 17. Server-Side Java: Sockets
Introduction
Section 17.1. Opening a Server for Business
Section 17.2. Returning a Response (String or Binary)
Section 17.3. Returning Object Information
Section 17.4. Handling Multiple Clients
Section 17.5. Serving the HTTP Protocol
Section 17.6. Securing a Web Server with SSL and JSSE
Section 17.7. Network Logging
Section 17.8. Network Logging with log4j
Section 17.9. Network Logging with JDK 1.4
Section 17.10. Finding Network Interfaces
Section 17.11. Program: A Java Chat Server
Chapter 18. Network Clients II: Applets and Web Clients
Introduction
Section 18.1. Embedding Java in a Web Page
Section 18.2. Applet Techniques
Section 18.3. Contacting a Server on the Applet Host
Section 18.4. Making an Applet Show a Document
Section 18.5. Making an Applet Run JavaScript
Section 18.6. Making an Applet Run a CGI Script
Section 18.7. Reading the Contents of a URL
Section 18.8. URI, URL, or URN?
Section 18.9. Extracting HTML from a URL
Section 18.10. Extracting URLs from a File
Section 18.11. Converting a Filename to a URL
Section 18.12. Program: MkIndex
Section 18.13. Program: LinkChecker
Chapter 19. Java and Electronic Mail
Introduction
Section 19.1. Sending Email: Browser Version
Section 19.2. Sending Email: For Real
Section 19.3. Mail-Enabling a Server Program
Section 19.4. Sending MIME Mail
Section 19.5. Providing Mail Settings
Section 19.6. Sending Mail without Using JavaMail
Section 19.7. Reading Email
Section 19.8. Program: MailReaderBean
Section 19.9. Program: MailClient
Chapter 20. Database Access
Introduction
Section 20.1. Easy Database Access with JDO
Section 20.2. Text-File Databases
Section 20.3. DBM Databases
Section 20.4. JDBC Setup and Connection
Section 20.5. Connecting to a JDBC Database
Section 20.6. Sending a JDBC Query and Getting Results
Section 20.7. Using JDBC Prepared Statements
Section 20.8. Using Stored Procedures with JDBC
Section 20.9. Changing Data Using a ResultSet
Section 20.10. Storing Results in a RowSet
Section 20.11. Changing Data Using SQL
Section 20.12. Finding JDBC Metadata
Section 20.13. Program: SQLRunner
Chapter 21. XML
Introduction
Section 21.1. Generating XML from Objects
Section 21.2. Transforming XML with XSLT
Section 21.3. Parsing XML with SAX
Section 21.4. Parsing XML with DOM
Section 21.5. Verifying Structure with a DTD
Section 21.6. Generating Your Own XML with DOM
Section 21.7. Program: xml2mif
Chapter 22. Distributed Java: RMI
Introduction
Section 22.1. Defining the RMI Contract
Section 22.2. Creating an RMI Client
Section 22.3. Creating an RMI Server
Section 22.4. Deploying RMI across a Network
Section 22.5. Program: RMI Callbacks
Section 22.6. Program: NetWatch
Chapter 23. Packages and Packaging
Introduction
Section 23.1. Creating a Package
Section 23.2. Documenting Classes with Javadoc
Section 23.3. Beyond JavaDoc: Annotations/Metadata (JDK 1.5) and XDoclet
Section 23.4. Archiving with jar
Section 23.5. Running an Applet from a JAR
Section 23.6. Running an Applet with a Modern JDK
Section 23.7. Running a Main Program from a JAR
Section 23.8. Preparing a Class as a JavaBean
Section 23.9. Pickling Your Bean into a JAR
Section 23.10. Packaging a Servlet into a WAR File
Section 23.11. "Write Once, Install Anywhere"
Section 23.12. "Write Once, Install on Mac OS X"
Section 23.13. Java Web Start
Section 23.14. Signing Your JAR File
Chapter 24. Threaded Java
Introduction
Section 24.1. Running Code in a Different Thread
Section 24.2. Displaying a Moving Image with Animation
Section 24.3. Stopping a Thread
Section 24.4. Rendezvous and Timeouts
Section 24.5. Synchronizing Threads with the synchronized Keyword
Section 24.6. Simplifying Synchronization with 1.5 Locks
Section 24.7. Synchronizing Threads with wait( ) and notifyAll( )
Section 24.8. Simplifying Producer-Consumer with the 1.5 Queue Interface
Section 24.9. Background Saving in an Editor
Section 24.10. Program: Threaded Network Server
Section 24.11. Simplifying Servers Using the Concurrency Utilities (JDK 1.5)
Chapter 25. Introspection, or "A Class Named Class"
Introduction
Section 25.1. Getting a Class Descriptor
Section 25.2. Finding and Using Methods and Fields
Section 25.3. Loading and Instantiating a Class Dynamically
Section 25.4. Constructing a Class from Scratch
Section 25.5. Performance Timing
Section 25.6. Printing Class Information
Section 25.7. Program: CrossRef
Section 25.8. Program: AppletViewer
Chapter 26. Using Java with Other Languages
Introduction
Section 26.1. Running a Program
Section 26.2. Running a Program and Capturing Its Output
Section 26.3. Mixing Java and Scripts with BSF
Section 26.4. Marrying Java and Perl
Section 26.5. Blending in Native Code (C/C++)
Section 26.6. Calling Java from Native Code
Section 26.7. Program: DBM
Overview of Chapters
Chapter 1. Getting Started: Compiling, Running, and Debugging
Introduction
Section 1.1. Compiling and Running Java: JDK
Section 1.2. Editing and Compiling with a Color-Highlighting Editor
Section 1.3. Compiling, Running, and Testing with an IDE
Section 1.4. Using CLASSPATH Effectively
Section 1.5. Using the com.darwinsys API Classes from This Book
Section 1.6. Compiling the Source Code Examples from This Book
Section 1.7. Automating Compilation with Ant
Section 1.8. Running Applets
Section 1.9. Dealing with Deprecation Warnings
Section 1.10. Conditional Debugging Without #ifdef
Section 1.11. Debugging Printouts
Section 1.12. Maintaining Program Correctness with Assertions
Section 1.13. Debugging with JDB
Section 1.14. Unit Testing: Avoid the Need for Debuggers
Section 1.15. Getting Readable Tracebacks
Section 1.16. Finding More Java Source Code
Section 1.17. Program: Debug
Chapter 2. Interacting with the Environment
Introduction
Section 2.1. Getting Environment Variables
Section 2.2. System Properties
Section 2.3. Writing JDK Release-Dependent Code
Section 2.4. Writing Operating System-Dependent Code
Section 2.5. Using Extensions or Other Packaged APIs
Section 2.6. Parsing Command-Line Arguments
Chapter 3. Strings and Things
Introduction
Section 3.1. Taking Strings Apart with Substrings
Section 3.2. Taking Strings Apart with StringTokenizer
Section 3.3. Putting Strings Together with +, StringBuilder and StringBuffer
Section 3.4. Processing a String One Character at a Time
Section 3.5. Aligning Strings
Section 3.6. Converting Between Unicode Characters and Strings
Section 3.7. Reversing a String by Word or by Character
Section 3.8. Expanding and Compressing Tabs
Section 3.9. Controlling Case
Section 3.10. Indenting Text Documents
Section 3.11. Entering Nonprintable Characters
Section 3.12. Trimming Blanks from the End of a String
Section 3.13. Parsing Comma-Separated Data
Section 3.14. Program: A Simple Text Formatter
Section 3.15. Program: Soundex Name Comparisons
Chapter 4. Pattern Matching with Regular Expressions
Introduction
Section 4.1. Regular Expression Syntax
Section 4.2. Using regexes in Java: Test for a Pattern
Section 4.3. Finding the Matching Text
Section 4.4. Replacing the Matched Text
Section 4.5. Printing All Occurrences of a Pattern
Section 4.6. Printing Lines Containing a Pattern
Section 4.7. Controlling Case in Regular Expressions
Section 4.8. Matching "Accented" or Composite Characters
Section 4.9. Matching Newlines in Text
Section 4.10. Program: Apache Logfile Parsing
Section 4.11. Program: Data Mining
Section 4.12. Program: Full Grep
Chapter 5. Numbers
Introduction
Section 5.1. Checking Whether a String Is a Valid Number
Section 5.2. Storing a Larger Number in a Smaller Number
Section 5.3. Converting Numbers to Objects and Vice Versa
Section 5.4. Taking a Fraction of an Integer Without Using Floating Point
Section 5.5. Ensuring the Accuracy of Floating-Point Numbers
Section 5.6. Comparing Floating-Point Numbers
Section 5.7. Rounding Floating-Point Numbers
Section 5.8. Formatting Numbers
Section 5.9. Converting Between Binary, Octal, Decimal, and Hexadecimal
Section 5.10. Operating on a Series of Integers
Section 5.11. Working with Roman Numerals
Section 5.12. Formatting with Correct Plurals
Section 5.13. Generating Random Numbers
Section 5.14. Generating Better Random Numbers
Section 5.15. Calculating Trigonometric Functions
Section 5.16. Taking Logarithms
Section 5.17. Multiplying Matrices
Section 5.18. Using Complex Numbers
Section 5.19. Handling Very Large Numbers
Section 5.20. Program: TempConverter
Section 5.21. Program: Number Palindromes
Chapter 6. Dates and Times
Introduction
Section 6.1. Finding Today's Date
Section 6.2. Printing Date/Time in a Given Format
Section 6.3. Representing Dates in Other Epochs
Section 6.4. Converting YMDHMS to a Calendar or Epoch Seconds
Section 6.5. Parsing Strings into Dates
Section 6.6. Converting Epoch Seconds to DMYHMS
Section 6.7. Adding to or Subtracting from a Date or Calendar
Section 6.8. Difference between Two Dates
Section 6.9. Comparing Dates
Section 6.10. Day of Week/Month/Year or Week Number
Section 6.11. Creating a Calendar Page
Section 6.12. Measuring Elapsed Time
Section 6.13. Sleeping for a While
Section 6.14. Program: Reminder Service
Chapter 7. Structuring Data with Java
Introduction
Section 7.1. Using Arrays for Data Structuring
Section 7.2. Resizing an Array
Section 7.3. Like an Array, but More Dynamic
Section 7.4. Using Iterators for Data-Independent Access
Section 7.5. Structuring Data in a Linked List
Section 7.6. Mapping with Hashtable and HashMap
Section 7.7. Storing Strings in Properties and Preferences
Section 7.8. Sorting a Collection
Section 7.9. Avoiding the Urge to Sort
Section 7.10. Eschewing Duplication
Section 7.11. Finding an Object in a Collection
Section 7.12. Converting a Collection to an Array
Section 7.13. Rolling Your Own Iterator
Section 7.14. Stack
Section 7.15. Multidimensional Structures
Section 7.16. Finally, Collections
Section 7.17. Program: Timing Comparisons
Chapter 8. Data Structuring with Generics, foreach, and Enumerations (JDK 1.5)
Introduction
Section 8.1. Using Generic Collections
Section 8.2. Using "foreach" Loops
Section 8.3. Avoid Casting by Using Generics
Section 8.4. Let Java Convert with AutoBoxing and AutoUnboxing
Section 8.5. Using Typesafe Enumerations
Section 8.6. Program: MediaInvoicer
Chapter 9. Object-Oriented Techniques
Introduction
Section 9.1. Printing Objects: Formatting with toString( )
Section 9.2. Overriding the Equals Method
Section 9.3. Overriding the hashCode Method
Section 9.4. The Clone Method
Section 9.5. The Finalize Method
Section 9.6. Using Inner Classes
Section 9.7. Providing Callbacks via Interfaces
Section 9.8. Polymorphism/Abstract Methods
Section 9.9. Passing Values
Section 9.10. Enforcing the Singleton Pattern
Section 9.11. Roll Your Own Exceptions
Section 9.12. Program: Plotter
Chapter 10. Input and Output
Introduction
Section 10.1. Reading Standard Input
Section 10.2. Writing Standard Output
Section 10.3. Printing with the 1.5 Formatter
Section 10.4. Scanning a File with StreamTokenizer
Section 10.5. Scanning Input with the 1.5 Scanner Class
Section 10.6. Opening a File by Name
Section 10.7. Copying a File
Section 10.8. Reading a File into a String
Section 10.9. Reassigning the Standard Streams
Section 10.10. Duplicating a Stream as It Is Written
Section 10.11. Reading/Writing a Different Character Set
Section 10.12. Those Pesky End-of-Line Characters
Section 10.13. Beware Platform-Dependent File Code
Section 10.14. Reading "Continued" Lines
Section 10.15. Binary Data
Section 10.16. Seeking
Section 10.17. Writing Data Streams from C
Section 10.18. Saving and Restoring Java Objects
Section 10.19. Preventing ClassCastExceptions with SerialVersionUID
Section 10.20. Reading and Writing JAR or Zip Archives
Section 10.21. Reading and Writing Compressed Files
Section 10.22. Program: Text to PostScript
Chapter 11. Directory and Filesystem Operations
Introduction
Section 11.1. Getting File Information
Section 11.2. Creating a File
Section 11.3. Renaming a File
Section 11.4. Deleting a File
Section 11.5. Creating a Transient File
Section 11.6. Changing File Attributes
Section 11.7. Listing a Directory
Section 11.8. Getting the Directory Roots
Section 11.9. Creating New Directories
Section 11.10. Program: Find
Chapter 12. Programming External Devices: Serial and Parallel Ports
Introduction
Section 12.1. Choosing a Port
Section 12.2. Opening a Serial Port
Section 12.3. Opening a Parallel Port
Section 12.4. Resolving Port Conflicts
Section 12.5. Reading and Writing: Lock-Step
Section 12.6. Reading and Writing: Event-Driven
Section 12.7. Reading and Writing: Threads
Section 12.8. Program: Penman Plotter
Chapter 13. Graphics and Sound
Introduction
Section 13.1. Painting with a Graphics Object
Section 13.2. Testing Graphical Components
Section 13.3. Drawing Text
Section 13.4. Drawing Centered Text in a Component
Section 13.5. Drawing a Drop Shadow
Section 13.6. Drawing Text with 2D
Section 13.7. Drawing Text with an Application Font
Section 13.8. Drawing an Image
Section 13.9. Playing a Sound File
Section 13.10. Playing a Video Clip
Section 13.11. Printing in Java
Section 13.12. Program: PlotterAWT
Section 13.13. Program: Grapher
Chapter 14. Graphical User Interfaces
Introduction
Section 14.1. Displaying GUI Components
Section 14.2. Designing a Window Layout
Section 14.3. A Tabbed View of Life
Section 14.4. Action Handling: Making Buttons Work
Section 14.5. Action Handling Using Anonymous Inner Classes
Section 14.6. Terminating a Program with "Window Close"
Section 14.7. Dialogs: When Later Just Won't Do
Section 14.8. Catching and Formatting GUI Exceptions
Section 14.9. Getting Program Output into a Window
Section 14.10. Choosing a Value with JSpinner
Section 14.11. Choosing a File with JFileChooser
Section 14.12. Choosing a Color
Section 14.13. Formatting JComponents with HTML
Section 14.14. Centering a Main Window
Section 14.15. Changing a Swing Program's Look and Feel
Section 14.16. Enhancing Your GUI for Mac OS X
Section 14.17. Program: Custom Font Chooser
Section 14.18. Program: Custom Layout Manager
Chapter 15. Internationalization and Localization
Introduction
Section 15.1. Creating a Button with I18N Resources
Section 15.2. Listing Available Locales
Section 15.3. Creating a Menu with I18N Resources
Section 15.4. Writing Internationalization Convenience Routines
Section 15.5. Creating a Dialog with I18N Resources
Section 15.6. Creating a Resource Bundle
Section 15.7. Extracting Strings from Your Code
Section 15.8. Using a Particular Locale
Section 15.9. Setting the Default Locale
Section 15.10. Formatting Messages
Section 15.11. Program: MenuIntl
Section 15.12. Program: BusCard
Chapter 16. Network Clients
Introduction
Section 16.1. Contacting a Server
Section 16.2. Finding and Reporting Network Addresses
Section 16.3. Handling Network Errors
Section 16.4. Reading and Writing Textual Data
Section 16.5. Reading and Writing Binary Data
Section 16.6. Reading and Writing Serialized Data
Section 16.7. UDP Datagrams
Section 16.8. Program: TFTP UDP Client
Section 16.9. Program: Telnet Client
Section 16.10. Program: Chat Client
Chapter 17. Server-Side Java: Sockets
Introduction
Section 17.1. Opening a Server for Business
Section 17.2. Returning a Response (String or Binary)
Section 17.3. Returning Object Information
Section 17.4. Handling Multiple Clients
Section 17.5. Serving the HTTP Protocol
Section 17.6. Securing a Web Server with SSL and JSSE
Section 17.7. Network Logging
Section 17.8. Network Logging with log4j
Section 17.9. Network Logging with JDK 1.4
Section 17.10. Finding Network Interfaces
Section 17.11. Program: A Java Chat Server
Chapter 18. Network Clients II: Applets and Web Clients
Introduction
Section 18.1. Embedding Java in a Web Page
Section 18.2. Applet Techniques
Section 18.3. Contacting a Server on the Applet Host
Section 18.4. Making an Applet Show a Document
Section 18.5. Making an Applet Run JavaScript
Section 18.6. Making an Applet Run a CGI Script
Section 18.7. Reading the Contents of a URL
Section 18.8. URI, URL, or URN?
Section 18.9. Extracting HTML from a URL
Section 18.10. Extracting URLs from a File
Section 18.11. Converting a Filename to a URL
Section 18.12. Program: MkIndex
Section 18.13. Program: LinkChecker
Chapter 19. Java and Electronic Mail
Introduction
Section 19.1. Sending Email: Browser Version
Section 19.2. Sending Email: For Real
Section 19.3. Mail-Enabling a Server Program
Section 19.4. Sending MIME Mail
Section 19.5. Providing Mail Settings
Section 19.6. Sending Mail without Using JavaMail
Section 19.7. Reading Email
Section 19.8. Program: MailReaderBean
Section 19.9. Program: MailClient
Chapter 20. Database Access
Introduction
Section 20.1. Easy Database Access with JDO
Section 20.2. Text-File Databases
Section 20.3. DBM Databases
Section 20.4. JDBC Setup and Connection
Section 20.5. Connecting to a JDBC Database
Section 20.6. Sending a JDBC Query and Getting Results
Section 20.7. Using JDBC Prepared Statements
Section 20.8. Using Stored Procedures with JDBC
Section 20.9. Changing Data Using a ResultSet
Section 20.10. Storing Results in a RowSet
Section 20.11. Changing Data Using SQL
Section 20.12. Finding JDBC Metadata
Section 20.13. Program: SQLRunner
Chapter 21. XML
Introduction
Section 21.1. Generating XML from Objects
Section 21.2. Transforming XML with XSLT
Section 21.3. Parsing XML with SAX
Section 21.4. Parsing XML with DOM
Section 21.5. Verifying Structure with a DTD
Section 21.6. Generating Your Own XML with DOM
Section 21.7. Program: xml2mif
Chapter 22. Distributed Java: RMI
Introduction
Section 22.1. Defining the RMI Contract
Section 22.2. Creating an RMI Client
Section 22.3. Creating an RMI Server
Section 22.4. Deploying RMI across a Network
Section 22.5. Program: RMI Callbacks
Section 22.6. Program: NetWatch
Chapter 23. Packages and Packaging
Introduction
Section 23.1. Creating a Package
Section 23.2. Documenting Classes with Javadoc
Section 23.3. Beyond JavaDoc: Annotations/Metadata (JDK 1.5) and XDoclet
Section 23.4. Archiving with jar
Section 23.5. Running an Applet from a JAR
Section 23.6. Running an Applet with a Modern JDK
Section 23.7. Running a Main Program from a JAR
Section 23.8. Preparing a Class as a JavaBean
Section 23.9. Pickling Your Bean into a JAR
Section 23.10. Packaging a Servlet into a WAR File
Section 23.11. "Write Once, Install Anywhere"
Section 23.12. "Write Once, Install on Mac OS X"
Section 23.13. Java Web Start
Section 23.14. Signing Your JAR File
Chapter 24. Threaded Java
Introduction
Section 24.1. Running Code in a Different Thread
Section 24.2. Displaying a Moving Image with Animation
Section 24.3. Stopping a Thread
Section 24.4. Rendezvous and Timeouts
Section 24.5. Synchronizing Threads with the synchronized Keyword
Section 24.6. Simplifying Synchronization with 1.5 Locks
Section 24.7. Synchronizing Threads with wait( ) and notifyAll( )
Section 24.8. Simplifying Producer-Consumer with the 1.5 Queue Interface
Section 24.9. Background Saving in an Editor
Section 24.10. Program: Threaded Network Server
Section 24.11. Simplifying Servers Using the Concurrency Utilities (JDK 1.5)
Chapter 25. Introspection, or "A Class Named Class"
Introduction
Section 25.1. Getting a Class Descriptor
Section 25.2. Finding and Using Methods and Fields
Section 25.3. Loading and Instantiating a Class Dynamically
Section 25.4. Constructing a Class from Scratch
Section 25.5. Performance Timing
Section 25.6. Printing Class Information
Section 25.7. Program: CrossRef
Section 25.8. Program: AppletViewer
Chapter 26. Using Java with Other Languages
Introduction
Section 26.1. Running a Program
Section 26.2. Running a Program and Capturing Its Output
Section 26.3. Mixing Java and Scripts with BSF
Section 26.4. Marrying Java and Perl
Section 26.5. Blending in Native Code (C/C++)
Section 26.6. Calling Java from Native Code
Section 26.7. Program: DBM
Reviewer: Krish Bhargav
Related Tips
Page 1 of 0 ( 0 comments )
Copyright 2005 - 2008 www.java-tips.org
Java is a trademark of Sun Microsystems, Inc.
You can share your information about this topic using the form below!
Please do not post your questions with this form! Thanks.