Copyright Preface New in This Edition Java Examples Online Related Books from O'Reilly Conventions Used in This Book Request for Comments Acknowledgments Part I: Learning Java Chapter 1. Java Basics Section 1.1. Hello World Section 1.2. FizzBuzz Section 1.3. The Fibonacci Series Section 1.4. Using Command-Line Arguments Section 1.5. Echo in Reverse Section 1.6. FizzBuzz Switched Section 1.7. Computing Factorials Section 1.8. Recursive Factorials Section 1.9. Caching Factorials Section 1.10. Computing Big Factorials Section 1.11. Handling Exceptions Section 1.12. Interactive Input Section 1.13. Using a StringBuffer Section 1.14. Sorting Numbers Section 1.15. Computing Primes Section 1.16. Exercises Chapter 2. Objects, Classes, and Interfaces Section 2.1. A Rectangle Class Section 2.2. Testing the Rect Class Section 2.3. A Rect Subclass Section 2.4. Another Subclass Section 2.5. Complex Numbers Section 2.6. Computing Statistics Section 2.7. An Integer List Section 2.8. Tokenizing Text Section 2.9. Exercises Part II: Core Java APIs Chapter 3. Input/Output Section 3.1. Files and Streams Section 3.2. Working with Files Section 3.3. Copying File Contents Section 3.4. Reading and Displaying Text Files Section 3.5. Listing Directory and File Information Section 3.6. Compressing Files and Directories Section 3.7. Filtering Character Streams Section 3.8. Tokenizing a Character Stream Section 3.9. Random Access to Files Section 3.10. Exercises Chapter 4. Threads Section 4.1. Thread Basics Section 4.2. Thread-Safe Classes Section 4.3. Threads and Thread Groups Section 4.4. Deadlock Section 4.5. Timers Section 4.6. Exercises Chapter 5. Networking Section 5.1. Downloading the Contents of a URL Section 5.2. Using a URLConnection Section 5.3. Sending Email Through a URLConnection Section 5.4. A Simple Network Client Section 5.5. A Generic Client Section 5.6. An HTTP Client Section 5.7. A POP Client Section 5.8. A Simple Web Server Section 5.9. A Proxy Server Section 5.10. A Generic Multithreaded Server Section 5.11. Sending Datagrams Section 5.12. Receiving Datagrams Section 5.13. Exercises Chapter 6. New I/O Section 6.1. Locking Files Section 6.2. Copying Files Section 6.3. Regular Expressions and Character Decoding Section 6.4. File Copying with Buffers Section 6.5. Advanced Byte-to-Character Conversion Section 6.6. Tokenizing Byte Buffers Section 6.7. A Simple HTTP Client Section 6.8. The Daytime Service Section 6.9. A Multiplexed Server Section 6.10. A Multiplexed Network Client Section 6.11. Exercises Chapter 7. Security and Cryptography Section 7.1. Running Untrusted Code Section 7.2. Loading Untrusted Code Section 7.3. Message Digests and Digital Signatures Section 7.4. Cryptography Section 7.5. Exercises Chapter 8. Internationalization Section 8.1. A Word About Locales Section 8.2. Unicode Section 8.3. Character Encodings Section 8.4. Handling Local Customs Section 8.5. Localizing User-Visible Messages Section 8.6. Formatted Messages Section 8.7. Exercises Chapter 9. Reflection Section 9.1. Obtaining Class and Member Information Section 9.2. Invoking a Named Method Section 9.3. Proxy Objects Section 9.4. Exercises Chapter 10. Object Serialization Section 10.1. Simple Serialization Section 10.2. Custom Serialization Section 10.3. Externalizable Classes Section 10.4. Serialization and Class Versioning Section 10.5. Exercises Part III: Desktop Java APIs Chapter 11. Graphical User Interfaces Section 11.1. Components Section 11.2. Containers Section 11.3. Layout Management Section 11.4. Event Handling Section 11.5. A Complete GUI Section 11.6. Actions and Reflection Section 11.7. Custom Dialogs Section 11.8. An Error Handler Dialog Section 11.9. Displaying Tables Section 11.10. Displaying Trees Section 11.11. A Simple Web Browser Section 11.12. Describing GUIs with Properties Section 11.13. Themes and the Metal Look-and-Feel Section 11.14. Look-and-Feel Preferences Section 11.15. The ShowBean Program Section 11.16. Exercises Chapter 12. Graphics Section 12.1. Graphics Before Java 1.2 Section 12.2. The Java 2D API Section 12.3. Drawing and Filling Shapes Section 12.4. Transforms Section 12.5. Line Styles with BasicStroke Section 12.6. Stroking Lines Section 12.7. Filling Shapes with Paint Section 12.8. Antialiasing Section 12.9. Combining Colors with AlphaComposite Section 12.10. Image Processing Section 12.11. Image I/O Section 12.12. Custom Shapes Section 12.13. Custom Strokes Section 12.14. Custom Paint Section 12.15. Advanced Animation Section 12.16. Displaying Graphics Examples Section 12.17. Exercises Chapter 13. Printing Section 13.1. Printing with the Java 1.1 API Section 13.2. Printing with the Java 1.2 API Section 13.3. Printing with the Java 1.4 API Section 13.4. Printing Multipage Text Documents Section 13.5. Advanced Printing with Java 1.4 Section 13.6. Exercises Chapter 14. Data Transfer Section 14.1. Simple Swing Data Transfer Section 14.2. A Clock with Drag and Copy Support Section 14.3. Data Transfer Architecture Section 14.4. Dropping Multiple Datatypes Section 14.5. A Transferable Shape Section 14.6. Custom Data Transfer Section 14.7. Exercises Chapter 15. JavaBeans Section 15.1. Bean Basics Section 15.2. A Simple Bean Section 15.3. A More Complex Bean Section 15.4. Custom Events Section 15.5. Specifying Bean Information Section 15.6. Defining a Simple Property Editor Section 15.7. Defining a Complex Property Editor Section 15.8. Defining a Bean Customizer Section 15.9. Manipulating Beans Section 15.10. Exercises Chapter 16. Applets Section 16.1. Introduction to Applets Section 16.2. A First Applet Section 16.3. A Clock Applet Section 16.4. A Timer Applet Section 16.5. Applets and the Java 1.0 Event Model Section 16.6. Exercises Chapter 17. Sound Section 17.1. Ringing the Bell Section 17.2. Swing Aural Cues Section 17.3. Playing Sounds with AudioClip Section 17.4. Playing Sounds with javax.sound Section 17.5. Streaming Sounds with javax.sound Section 17.6. Synthesizing a MIDI Sequence Section 17.7. Real-Time MIDI Sounds Section 17.8. Exercises Part IV: Enterprise Java APIs Chapter 18. Database Access with SQL Section 18.1. Accessing a Database Section 18.2. Using Database Metadata Section 18.3. Building a Database Section 18.4. Using the API Database Section 18.5. Atomic Transactions Section 18.6. Exercises Chapter 19. XML Section 19.1. Parsing with JAXP and SAX Section 19.2. Parsing and Manipulating with JAXP and DOM Section 19.3. Transforming XML with XSLT Section 19.4. An XML Pull Parser Section 19.5. Exercises Chapter 20. Servlets and JavaServer Pages Section 20.1. Servlet Setup Section 20.2. A Hello World Servlet Section 20.3. Another Simple Servlet Section 20.4. Servlet Initialization and Persistence: A Counter Servlet Section 20.5. Hello JSP Section 20.6. Hello JSP2 Section 20.7. Hello XML Section 20.8. The MVC Paradigm for Web Applications Section 20.9. ListManager Model Classes Section 20.10. ListManager Controller Section 20.11. ListManager Views Section 20.12. Custom Tags in JSP 2.0 Section 20.13. Packaging a Web Application Section 20.14. Exercises Chapter 21. Remote Method Invocation Section 21.1. Remote Banking Section 21.2. A Bank Server Section 21.3. A Persistent Bank Server Section 21.4. A Multiuser Domain Section 21.5. Remote MUD Interfaces Section 21.6. The MUD Server Section 21.7. The MudPlace Class Section 21.8. The MudPerson Class Section 21.9. A MUD Client Section 21.10. Advanced RMI Section 21.11. Exercises Chapter 22. Example Index Section 22.1. Symbols Section 22.2. A Section 22.3. B Section 22.4. C Section 22.5. D Section 22.6. E Section 22.7. F Section 22.8. G Section 22.9. H Section 22.10. I Section 22.11. J Section 22.12. K Section 22.13. L Section 22.14. M Section 22.15. N Section 22.16. O Section 22.17. P Section 22.18. Q Section 22.19. R Section 22.20. S Section 22.21. T Section 22.22. U Section 22.23. V Section 22.24. W Section 22.25. X Section 22.26. Y Section 22.27. Z Colophon Index