Java Examples in a Nutshell, 3/e

David Flanagan

  • 出版商: O'Reilly|英文2書85折
  • 出版日期: 2004-02-24
  • 定價: $1,380
  • 售價: 5.0$690
  • 語言: 英文
  • 頁數: 720
  • 裝訂: Paperback
  • ISBN: 0596006209
  • ISBN-13: 9780596006204
  • 相關分類: Java 程式語言
  • 立即出貨

買這商品的人也買了...

相關主題

商品描述

The author of the best-selling Java in a Nutshell has created an entire book of real-world Java programming examples that you can learn from. If you learn best "by example," this is the book for you.

This third edition covers Java 1.4 and contains 193 complete, practical examples: over 21,900 lines of densely commented, professionally written Java code, covering 20 distinct client-side and server-side APIs. It includes new chapters on the Java Sound API and the New I/O API. The chapters on XML and servlets have been rewritten to cover the latest versions of the specifications and to demonstrate best practices for Java 1.4. New and updated examples throughout the book demonstrate many other new Java features and APIs.

Java Examples in a Nutshell is a companion volume to Java in a Nutshell, Java Foundation Classes in a Nutshell, and Java Enterprise in a Nutshell. It picks up where those quick references leave off, providing a wealth of examples for both novices and experts. This book doesn't hold your hand; it simply delivers well-commented working examples with succinct explanations to help you learn and explore Java and its APIs.

Java Examples in a Nutshell contains examples that demonstrate:

  • Core APIs, including I/O, New I/O, threads, networking, security, serialization, and reflection
  • Desktop APIs, highlighting Swing GUIs, Java 2D graphics, preferences, printing, drag-and-drop, JavaBeans, applets, and sound
  • Enterprise APIs, including JDBC (database access), JAXP (XML parsing and transformation), Servlets 2.4, JSP 2.0 (JavaServer Pages), and RMI

The book begins with introductory examples demonstrating structured and object-oriented programming techniques for new Java programmers. A special index at the end of the book makes it easy to look up examples that use a particular Java class or accomplish a desired task. In between, each chapter includes exercises that challenge readers and suggest further avenues for exploration

Table of Contents

Preface

I. Learning Java

1. Java Basics
     Hello World
     FizzBuzz
     The Fibonacci Series
     Using Command-Line Arguments
     Echo in Reverse
     FizzBuzz Switched
     Computing Factorials
     Recursive Factorials
     Caching Factorials
     Computing Big Factorials
     Handling Exceptions
     Interactive Input
     Using a StringBuffer
     Sorting Numbers
     Computing Primes

2. Objects, Classes, and Interfaces
     A Rectangle Class
     Testing the Rect Class
     A Rect Subclass
     Another Subclass
     Complex Numbers
     Computing Statistics
     An Integer List
     Tokenizing Text

II. Core Java APIs

3. Input/Output
     Files and Streams
     Working with Files
     Copying File Contents
     Reading and Displaying Text Files
     Listing Directory and File Information
     Compressing Files and Directories
     Filtering Character Streams
     Tokenizing a Character Stream
     Random Access to Files

4. Threads
     Thread Basics
     Thread-Safe Classes
     Threads and Thread Groups
     Deadlock
     Timers

5. Networking
     Downloading the Contents of a URL
     Using a URLConnection
     Sending Email Through a URLConnection
     A Simple Network Client
     A Generic Client
     An HTTP Client
     A POP Client
     A Simple Web Server
     A Proxy Server
     A Generic Multithreaded Server
     Sending Datagrams
     Receiving Datagrams

6. New I/O
     Locking Files
     Copying Files
     Regular Expressions and Character Decoding
     File Copying with Buffers
     Advanced Byte-to-Character Conversion
     Tokenizing Byte Buffers
     A Simple HTTP Client
     The Daytime Service
     A Multiplexed Server
     A Multiplexed Network Client

7. Security and Cryptography
     Running Untrusted Code
     Loading Untrusted Code
     Message Digests and Digital Signatures
     Cryptography

8. Internationalization
     A Word About Locales
     Unicode
     Character Encodings
     Handling Local Customs
     Localizing User-Visible Messages
     Formatted Messages

9. Reflection
     Obtaining Class and Member Information
     Invoking a Named Method
     Proxy Objects

10. Object Serialization
     Simple Serialization
     Custom Serialization
     Externalizable Classes
     Serialization and Class Versioning

III. Desktop Java APIs

11. Graphical User Interfaces
     Components
     Containers
     Layout Management
     Event Handling
     A Complete GUI
     Actions and Reflection
     Custom Dialogs
     An Error Handler Dialog
     Displaying Tables
     Displaying Trees
     A Simple Web Browser
     Describing GUIs with Properties
     Themes and the Metal Look-and-Feel
     Look-and-Feel Preferences
     The ShowBean Program

12. Graphics
     Graphics Before Java 1.2
     The Java 2D API
     Drawing and Filling Shapes
     Transforms
     Line Styles with BasicStroke
     Stroking Lines
     Filling Shapes with Paint
     Antialiasing
     Combining Colors with AlphaComposite
     Image Processing
     Image I/O
     Custom Shapes
     Custom Strokes
     Custom Paint
     Advanced Animation
     Displaying Graphics Examples

13. Printing
     Printing with the Java 1.1 API
     Printing with the Java 1.2 API
     Printing with the Java 1.4 API
     Printing Multipage Text Documents
     Advanced Printing with Java 1.4

14. Data Transfer
     Simple Swing Data Transfer
     A Clock with Drag and Copy Support
     Data Transfer Architecture
     Dropping Multiple Datatypes
     A Transferable Shape
     Custom Data Transfer

15. JavaBeans
     Bean Basics
     A Simple Bean
     A More Complex Bean
     Custom Events
     Specifying Bean Information
     Defining a Simple Property Editor
     Defining a Complex Property Editor
     Defining a Bean Customizer
     Manipulating Beans

16. Applets
     Introduction to Applets
     A First Applet
     A Clock Applet
     A Timer Applet
     Applets and the Java 1.0 Event Model

17. Sound
     Ringing the Bell
     Swing Aural Cues
     Playing Sounds with AudioClip
     Playing Sounds with javax.sound
     Streaming Sounds with javax.sound
     Synthesizing a MIDI Sequence
     Real-Time MIDI Sounds

IV. Enterprise Java APIs

18. Database Access with SQL
     Accessing a Database
     Using Database Metadata
     Building a Database
     Using the API Database
     Atomic Transactions

19. XML
     Parsing with JAXP and SAX
     Parsing and Manipulating with JAXP and DOM
     Transforming XML with XSLT
     An XML Pull Parser

20. Servlets and JavaServer Pages
     Servlet Setup
     A Hello World Servlet
     Another Simple Servlet
     Servlet Initialization and Persistence: A Counter Servlet
     Hello JSP
     Hello JSP2
     Hello XML
     The MVC Paradigm for Web Applications
     ListManager Model Classes
     ListManager Controller
     ListManager Views
     Custom Tags in JSP 2.0
     Packaging a Web Application

21. Remote Method Invocation
     Remote Banking
     A Bank Server
     A Persistent Bank Server
     A Multiuser Domain
     Remote MUD Interfaces
     The MUD Server
     The MudPlace Class
     The MudPerson Class
     A MUD Client
     Advanced RMI

22. Example Index

Index

商品描述(中文翻譯)

暢銷書《Java in a Nutshell》的作者創作了一本充滿實用Java編程示例的書籍,讓您可以從中學習。如果您喜歡「以實例為例」的學習方式,這本書非常適合您。這本第三版涵蓋了Java 1.4,包含了193個完整的實用示例:超過21,900行密集註釋的專業Java代碼,涵蓋了20個不同的客戶端和服務器端API。它新增了關於Java Sound API和New I/O API的章節。XML和servlet的章節已經重寫,以涵蓋最新版本的規範並展示Java 1.4的最佳實踐。整本書中的新示例和更新示例展示了許多其他新的Java功能和API。《Java Examples in a Nutshell》是《Java in a Nutshell》、《Java Foundation Classes in a Nutshell》和《Java Enterprise in a Nutshell》的配套書籍。它繼續了這些快速參考書的內容,為初學者和專家提供了豐富的示例。這本書不會牽著你的手,它只是提供了註釋良好的工作示例和簡潔的解釋,幫助您學習和探索Java及其API。《Java Examples in a Nutshell》包含了以下示例:核心API,包括I/O、New I/O、線程、網絡、安全、序列化和反射;桌面API,重點介紹Swing GUI、Java 2D圖形、首選項、打印、拖放、JavaBeans、小程序和聲音;企業API,包括JDBC(數據庫訪問)、JAXP(XML解析和轉換)、Servlets 2.4、JSP 2.0(JavaServer Pages)和RMI。本書以介紹性示例開始,展示了新Java程序員的結構化和面向對象編程技巧。書末的特殊索引使得查找使用特定Java類的示例或實現特定任務變得輕鬆。在各章之間,每個章節都包含了挑戰讀者並提出進一步探索的練習題。目錄如下:

前言

I. 學習Java

1. Java基礎
- Hello World
- FizzBuzz
- 費氏數列
- 使用命令行參數
- 反向回顯
- FizzBuzz切換
- 計算階乘
- 遞歸階乘
- 緩存階乘
- 計算大數階乘
- 處理異常
- 交互式輸入
- 使用StringBuffer
- 排序數字
- 計算質數

2. 對象、類和接口
- 矩形類
- 測試Rect類
- 矩形子類
- 另一個子類
- 複數
- 計算統計
- 整數列表
- 分詞文本

II. 核心Java API

3. 輸入/輸出
- 文件和流
- 使用文件
- 複製文件內容
- 讀取和顯示文本文件
- 列出目錄和文件信息
- 壓縮文件和目錄
- 過濾字符流
- 分詞字符流
- 隨機訪問文件

4. 線程
- 線程B