本書是經典的《Java核心技術卷Ⅱ:高級特性》的新版。這一版對全書進行了全面更新,以反映Java SE 9、Java SE 10和Java SE 11的特性。 本書是Java技術權威指南,全面覆蓋Java技術的高級主題,包括流,輸入與輸出,XML,網路API,資料庫編程,日期與時間API,國際化,腳本、編譯與註解處理,Java平台模塊系統,安全,本地方法等內容。本書對Java技術的闡述精確到位,敘述方式深入淺出,並包含大量程序示例,從而幫助讀者充分理解Java語言以及Java類庫的相關高級特性。 本書適合想將Java應用於實際項目的軟體開發人員、高等院校教師和學生參考閱讀。
作者介紹
(美)凱·S.霍斯特曼|責編:楊海玲
目錄
Chapter 1:Streams / 流 1.1 From Iterating to Stream Operations / 從迭代到流操作 1.2 Stream Creation / 流的創建 1.3 The filter, map, and flatMap Methods / filter、map和flatMap方法 1.4 Extracting Substreams and Combining Streams / 提取子流和組合流 1.5 Other Stream Transformations / 其他流變換 1.6 Simple Reductions / 簡單規約 1.7 The Optional Type / Optional類型 1.7.1 Getting an Optional Value / 獲得Optional值 1.7.2 Consuming an Optional Value / 消耗Optional值 1.7.3 Pipelining Optional Values / 流水線式的使用Optional值 1.7.4 How Not to Work with Optional Values / 避免錯誤使用Optional值 1.7.5 Creating Optional Values / 創建Optional值 1.7.6 Composing Optional Value Functions with flatMap / 使用flatMap組合Optional值函數 1.7.7 Turning an Optional into a Stream / 將Optional值變到流中 1.8 Collecting Results / 收集結果 1.9 Collecting into Maps / 收集到Map中 1.10 Grouping and Partitioning / 分組與分區 1.11 Downstream Collectors / 下游的收集器 1.12 Reduction Operations / 規約操作 1.13 Primitive Type Streams / 基本類型的流 1.14 Parallel Streams / 並行流 Chapter 2:Input and Output / 輸入與輸出 2.1 Input / Output Streams / 輸入/輸出流 2.1.1 Reading and Writing Bytes / 讀寫位元組 2.1.2 The Complete Stream Zoo / 流譜系概覽 2.1.3 Combining Input/Output Stream Filters / 組合輸入/輸出流過濾器 2.1.4 Text Input and Output / 文本輸入與輸出 2.1.5 How to Write Text Output / 輸出文本 2.1.6 How to Read Text Input / 輸入文本 2.1.7 Saving Objects in Text Format / 以文本格式保存對象 2.1.8 Character Encodings / 字元編碼 2.2 Reading and Writing Binary Data / 讀寫二進位數據 2.2.1 The DataInput and DataOutput interfaces / DataInput和DataOutput介面 2.2.2 Random-Access Files / 隨機訪問文件 2.2.3 ZIP Archives / ZIP文檔 2.3 Object Input/Output Streams and Serialization / 對象輸入/輸出流與序列化 2.3.1 Saving and Loading Serializable Objects / 序列化對象的保存與載入 2.3.2 Understanding the Object Serialization File Format / 理解對象序列化文件格式 2.3.3 Modifying the Default Serialization Mechanism / 修改默認的序列化機制 2.3.4 Serializing Singletons and Typesafe Enumerations / 序列化單例和類型安全的枚舉 2.3.5 Versioning / 版本管理 2.3.6 Using Serialization for Cloning / 將序列化用於克隆 2.4 Working with Files / 處理文件 2.4.1 Paths / 路徑 2.4.2 Reading and Writing Files / 讀寫文件 2.4.3 Creating Files and Directories / 創建文件和目錄 2.4.4 Copying, Moving, and Deleting Files / 複製、移動和刪除文件 2.4.5 Getting File Info 2.4.7 Using Directory Streams / 使用目錄流 2.4.8 ZIP File Systems / ZIP文件系統 2.5 Memory-Mapped Files / 內存映射文件 2.5.1 Memory-Mapped File Performance / 內存映射文件的性能 2.5.2 The Buffer Data Structure / 緩衝區數據結構 2.6 File Locking / 文件鎖 2.7 Regular Expressions / 正則表達式 2.7.1 The Regular Expression Syntax / 正則表達式語法 2.7.2 Matching a String / 匹配字元串 2.7.3 Finding Multiple Matches / 尋找多個匹配字元串 2.7.4 Splitting along Delimiters / 使用分隔符分解 2.7.5 Replacing Matches / 替換掉匹配字元串 Chapter 3:XML 3.1 Introducing XML / XML簡介 3.2 The Structure of an XML Document / XML文檔的結構 3.3 Parsing an XML Document / 解析XML文檔 3.4 Validating XML Documents / 驗證XML文檔 3.4.1 Document Type Definitions / 文檔類型定義 3.4.2 XML Schema / XML模式 3.4.3 A Practical Example / 實用示例 3.5 Locating Information with XPath / 使用XPath定位信息 3.6 Using Namespaces / 使用命名空間 3.7 Streaming Parsers / 流解析器 3.7.1 Using the SAX Parser / 使用SAX解析器 3.7.2 Using the StAX Parser / 使用StAX解析器 3.8 Generating XML Documents / 生成XML文檔 3.8.1 Documents without Namespaces / 不帶命名空間的文檔 3.8.2 Documents with Namespaces / 帶命名空間的文檔 3.8.3 Writing Documents / 寫文檔 3.8.4 Writing an XML Document with StAX / 使用StAX寫XML文檔 3.8.5 An Example:Generating an SVG File / 示例:生成SVG文件 3.9 XSL Transformations / XSL轉換 Chapter 4:Networking / 網路 4.1 Connecting to a Server / 連接到伺服器 4.1.1 Using Telnet / 使用Telnet 4.1.2 Connecting to a Server with Java / 使用Java連接到伺服器 4.1.3 Socket Timeouts / 套接字超時 4.1.4 Internet Addresses / 網際網路地址 4.2 Implementing Servers / 實現伺服器 4.2.1 Server Sockets / 伺服器套接字 4.2.2 Serving Multiple Clients / 服務多個客戶端 4.2.3 Half-Close / 半關閉 4.2.4 Interruptible Sockets / 可中斷套接字 4.3 Getting Web Data / 獲取Web數據 4.3.1 URLs and URIs / URL和URI 4.3.2 Using a URLConnection to Retrieve Information / 使用URLConnection獲取信息 4.3.3 Posting Form Data / 提交表單數據 4.4 The HTTP Client / HTTP客戶端 4.5 Sending E-Mail / 發送E-Mail Chapter 5:Database Programming / 資料庫編程
5.1 The Design of JDBC / JDBC的設計 5.1.1 JDBC Driver Types / JDBC驅動程序分類 5.1.2 Typical Uses of JDBC / JDBC的典型用法 5.2 The Structured Query Language / 結構化查詢語言 5.3 JDBC Configuration / JDBC配置 5.3.1 Database URLs / 資料庫URL 5.3.2 Driver JAR Files / 驅動程序JAR文件 5.3.3 Starting the Database / 啟動資料庫 5.3.4 Registering the Driver Class / 註冊驅動程序類 5.3.5 Connecting to the Database / 連接到資料庫 5.4 Working with JDBC Statements / 使用JDBC語句 5.4.1 Executing SQL Statements / 執行SQL語句 5.4.2 Managing Connections, Statements, and Result Sets / 管理連接、語句和結果集 5.4.3 Analyzing SQL Exceptions / 分析SQL異常 5.4.4 Populating a Database / 填充資料庫 5.5 Query Execution / 執行查詢 5.5.1 Prepared Statements / 預備語句 5.5.2 Reading and Writing LOBs / 讀寫LOB 5.5.3 SQL Escapes / SQL轉義 5.5.4 Multiple Results / 多結果集 5.5.5 Retrieving Autogenerated Keys / 獲取自動生成的主鍵 5.6 Scrollable and Updatable Result Sets / 可滾動和可更新的結果集 5.6.1 Scrollable Result Sets / 可滾動的結果集 5.6.2 Updatable Result Sets / 可更新的結果集 5.7 Row Sets / 行集 5.7.1 Constructing Row Sets / 構建行集 5.7.2 Cached Row Sets / 緩存的行集 5.8 Metadata / 元數據 5.9 Transactions / 事務 5.9.1 Programming Transactions with JDBC / 使用JDBC編程實現事務 5.9.2 Save Points / 保存點 5.9.3 Batch Updates / 批量更新 5.9.4 Advanced SQL Types / 高級SQL類型 5.10 Connection Management in Web and Enterprise Applications / Web與企業應用中的連接管理 Chapter 6:The Date and Time API / 日期與時間API 6.1 The Time Line / 時間線 6.2 Local Dates / 本地日期 6.3 Date Adjusters / 日期調整 6.4 Local Time / 本地時間 6.5 Zoned Time / 時區時間 6.6 Formatting and Parsing / 格式化與解析 6.7 Interoperating with Legacy Code / 與遺留代碼互操作 Chapter 7:Internationalization / 國際化 7.1 Locales / 地域 7.1.1 Why Locales / 為什麼要引入地域類 7.1.2 Specifying Locales / 指定地域 7.1.3 The Default Locale / 默認地域 7.1.4 Display Names / 顯示地域名 7.2 Number Formats / 數字格式 7.2.1 Formatting Numeric Values / 格式化數字值
7.2.2 Currencies / 貨幣 7.3 Date and Time / 日期與時間 7.4 Collation and Normalization / 排序規則與標準化 7.5 Message Formatting / 消息格式化 7.5.1 Formatting Numbers and Dates / 格式化數字和日期 7.5.2 Choice Formats / choice格式化選項 7.6 Text Input and Output / 文本輸入與輸出 7.6.1 Text Files / 文本文件 7.6.2 Line Endings / 文本行結尾符號 7.6.3 The Console / 控制台 7.6.4 Log Files / 日誌文件 7.6.5 The UTF-8 Byte Order Mark / UTF-8位元組順序標記 7.6.6 Character Encoding of Source Files / 源文件的字元編碼 7.7 Resource Bundles / 資源包 7.7.1 Locating Resource Bundles / 定位資源包 7.7.2 Property Files / 屬性文件 7.7.3 Bundle Classes / 包類 7.8 A Complete Example / 完整示例 Chapter 8:Scripting, Compiling, and Annotation Processing / 腳本、編譯與註解處理 8.1 Scripting for the Java Platform / Java平台的腳本 8.1.1 Getting a Scripting Engine / 獲得腳本引擎 8.1.2 Script Evaluation and Bindings / 腳本求值與綁定 8.1.3 Redirecting Input and Output / 重定向輸入輸出 8.1.4 Calling Scripting Functions and Methods / 調用腳本函數和方法 8.1.5 Compiling a Script / 編譯腳本 8.1.6 An Example:Scripting GUI Events / 示例:用腳本處理GUI事件 8.2 The Compiler API / 編譯器API 8.2.1 Invoking the Compiler / 調用編譯器 8.2.2 Launching a Compilation Task / 啟動編譯任務 8.2.3 Capturing Diagnostics / 捕獲診斷信息 8.2.4 Reading Source Files from Memory / 從內存讀取源文件 8.2.5 Writing Byte Codes to Memory / 將位元組碼寫入內存 8.2.6 An Example:Dynamic Java Code Generation / 示例:動態Java代碼生成 8.3 Using Annotations / 使用註解 8.3.1 An Introduction into Annotations / 註解簡介 8.3.2 An Example:Annotating Event Handlers / 示例:註解事件處理程序 8.4 Annotation Syntax / 註解語法 8.4.1 Annotation Interfaces / 註解介面 8.4.2 Annotations / 註解 8.4.3 Annotating Declarations / 在聲明的地方使用註解 8.4.4 Annotating Type Uses / 在類型使用的地方使用註解 8.4.5 Annotating this / 對this做註解 8.5 Standard Annotations / 標準註解 8.5.1 Annotations for Compilation / 用於編譯的註解 8.5.2 Annotations for Managing Resources / 用於管理資源的註解 8.5.3 Meta-Annotations / 元註解 8.6 Source-Level Annotation Processing / 源碼級註解處理 8.6.1 Annotation Processors / 註解處理器 8.6.2 The Language Model API / 語言模型API 8.6.3 Using Annotations to Generate Source Code / 使用註解生成源代碼
8.7 Bytecode Engineering / 位元組碼工程 8.7.1 Modifying Class Files / 修改類文件 8.7.2 Modifying Bytecodes at Load Time / 在載入時修改位元組碼 Chapter 9:The Java Platform Module System / Java平台模塊系統 9.1 The Module Concept / 模塊概念 9.2 Naming Modules / 命名模塊 9.3 The Modular「Hello, World!」Program / 模塊化的「Hello, World!」程序 9.4 Requiring Modules / 請求模塊 9.5 Exporting Packages / 導出包 9.6 Modular JARs / 模塊化的JAR文件 9.7 Modules and Reflective Access / 模塊與反射訪問 9.8 Automatic Modules / 自動模塊 9.9 The Unnamed Module / 未命名模塊 9.10 Command-Line Flags for Migration / 用於遷移的命令行標誌 9.11 Transitive and Static Requirements / 傳遞和靜態請求 9.12 Qualified Exporting and Opening / 限制導出和打開 9.13 Service Loading / 服務載入 9.14 Tools for Working with Modules / 處理模塊的工具 Chapter 10:Security / 安全 10.1 Class Loaders / 類載入器 10.1.1 The Class-Loading Process / 類載入流程 10.1.2 The Class Loader Hierarchy / 類載入器層次結構 10.1.3 Using Class Loaders as Namespaces / 將類載入器作為命名空間 10.1.4 Writing Your Own Class Loader / 編寫自己的類載入器 10.1.5 Bytecode Verification / 位元組碼驗證 10.2 Security Managers and Permissions / 安全管理器與許可權 10.2.1 Permission Checking / 許可權檢查 10.2.2 Java Platform Security / Java平台安全 10.2.3 Security Policy Files / 安全策略文件 10.2.4 Custom Permissions / 定製許可權 10.2.5 Implementation of a Permission Class / 實現許可權類 10.3 User Authentication / 用戶認證 10.3.1 The JAAS Framework / JAAS框架 10.3.2 JAAS Login Modules / JAAS登錄模塊 10.4 Digital Signatures / 數字簽名 10.4.1 Message Digests / 消息摘要 10.4.2 Message Signing / 消息簽名 10.4.3 Verifying a Signature / 驗證簽名 10.4.4 The Authentication Problem / 認證問題 10.4.5 Certificate Signing / 證書籤名 10.4.6 Certificate Requests / 證書請求 10.4.7 Code Signing / 代碼簽名 10.5 Encryption / 加密 10.5.1 Symmetric Ciphers / 對稱密碼 10.5.2 Key Generation / 生成密鑰 10.5.3 Cipher Streams / 加密流 10.5.4 Public Key Ciphers / 公鑰密碼 Chapter 11:Advanced Swing and Graphics / 高級Swing和圖形編程 11.1 Tables / 表格 11.1.1 A Simple Table / 簡單表格
11.1.2 Table Models / 表格模式 11.1.3 Working with Rows and Columns / 行列操作 11.1.3.1 Column Classes / 列類 11.1.3.2 Accessing Table Columns / 訪問表列 11.1.3.3 Resizing Columns / 調整列 11.1.3.4 Resizing Rows / 調整行 11.1.3.5 Selecting Rows, Columns, and Cells / 選擇行、列和單元格 11.1.3.6 Sorting Rows / 對行進行排序 11.1.3.7 Filtering Rows / 對行進行過濾 11.1.3.8 Hiding and Displaying Columns / 隱藏或顯示列 11.1.4 Cell Rendering and Editing / 單元格的繪製和編輯 11.1.4.1 Rendering Cells / 繪製單元格 11.1.4.2 Rendering the Header / 繪製表頭 11.1.4.3 Editing Cells / 編輯單元格 11.1.4.4 Custom Editors / 定製編輯器 11.2 Trees / 樹 11.2.1 Simple Trees / 簡單的樹 11.2.2 Node Enumeration / 節點枚舉 11.2.3 Rendering Nodes / 渲染節點 11.2.4 Listening to Tree Events / 監聽樹事件 11.2.5 Custom Tree Models / 定製樹模型 11.3 Advanced AWT / 高級AWT 11.3.1 The Rendering Pipeline / 繪製圖形的流程 11.3.2 Shapes / 形狀 11.3.2.1 The Shape Class Hierarchy / Shape類層次結構 11.3.2.2 Using the Shape Classes / 使用各種Shape類 11.3.3 Areas / 區域 11.3.4 Strokes / 畫筆 11.3.5 Paint / 著色 11.3.6 Coordinate Transformations / 坐標變換 11.3.7 Clipping / 剪切 11.3.8 Transparency and Composition / 透明和組合 11.4 Raster Images / 光柵圖像 11.4.1 Readers and Writers for Images / 圖像的讀取器和寫入器 11.4.1.1 Obtaining Readers and Writers for Image File Types / 獲取圖像文件類型的讀取器和寫入器 11.4.1.2 Reading and Writing Files with Multiple Images / 讀寫包含多個圖像的文件 11.4.2 Image Manipulation / 圖像處理 11.4.2.1 Constructing Raster Images / 構建光柵圖像 11.4.2.2 Filtering Images / 圖像過濾 11.5 Printing / 列印 11.5.1 Graphics Printing / 圖形列印 11.5.2 Multiple-Page Printing / 多頁列印 11.5.3 Print Services / 列印服務 11.5.4 Stream Print Services / 流列印服務 11.5.5 Printing Attributes / 列印屬性 Chapter 12:Native Methods / 本地方法 12.1 Calling a C Function from a Java Program / 從Java程序中調用C函數 12.2 Numeric Parameters and Return Values / 數值參數與返回值 12.3 String Parameters / 字元串參數 12.4 A 12.4.1 Accessing Instance Fields / 訪問實例欄位 12.4.2 Accessing Static Fields / 訪問靜態欄位 12.5 Encoding Signatures / 編碼簽名 12.6 Calling Java Methods / 調用Java方法 12.6.1 Instance Methods / 實例方法 12.6.2 Static Methods / 靜態方法 12.6.3 Constructors / 構造器 12.6.4 Alternative Method Invocations / 其他調用方法的手段 12.7 Accessing Array Elements / 訪問數組元素 12.8 Handling Errors / 處理錯誤 12.9 Using the Invocation API / 使用Invocation API 12.10 A Complete Example:Accessing the Windows Registry / 完整示例:訪問Windows註冊表 12.10.1 Overview of the Windows Registry / Windows註冊表簡介 12.10.2 A Java Platform Interface for Accessing the Registry / 訪問註冊表的Java平台介面 12.10.3 Implementation of Registry Access Functions as Native Methods / 以本地方法方式實現註冊表訪問功能