Core Java Volume II (Cay S. Horstmann) (z-library.sk, 1lib.sk, z-lib.sk)
Author: Cay S. Horstmann
Java
No Description
📄 File Format:
PDF
💾 File Size:
17.6 MB
9
Views
0
Downloads
0.00
Total Donations
📄 Text Preview (First 20 pages)
ℹ️
Registered users can read the full content for free
Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.
📄 Page
1
(This page has no text content)
📄 Page
2
(This page has no text content)
📄 Page
3
Core Java Volume II: Advanced Features Fourteenth Edition Cay S. Horstmann
📄 Page
4
. Cover image: surangaw/stock.adobe.com Figures 3.3, 4.8: Mozilla Foundation Figures 4.1-4.5, 5.3, 5.4: Microsoft Corporation Figure 4.6: USPS Figures 5.6, 7.1-7.6, 9.7, 10.1, 10.3, 10.8, 10.10, 10.11, 10.14-10.16, 11.4, 11.5, 11.8-11.27, 11.29-11.34, 12.1-12.5, 12.7-12.10, 12.14-12.26, 12.28-12.30, 12.39, 12.44-12.46, 12.54-12.56, 12.60, 12.62: Oracle Corporation Figure 9.3: HHD Software Ltd Figure 12.51: Shao-Chun Wang/123RF Figures 12.57-12.59: Pearson Education Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and the publisher was aware of a trademark claim, the designations have been printed with initial capital letters or in all capitals. The author and publisher have taken care in the preparation of this book, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for incidental or consequential damages in connection with or arising out of the use of the information or programs contained herein. Please contact us with concerns about any potential bias at pearson.com/en- us/report-bias.html. Author websites are not owned or managed by Pearson. Visit us on the Web: informit.com Library of Congress Control Number: 2025945104 Copyright © 2026 Pearson Education, Inc. Hoboken, New Jersey Portions copyright © 1996-2013 Oracle and/or its affiliates. All Rights Reserved. Oracle America Inc. does not make any representations or warranties as to the accuracy, adequacy or completeness of any information contained in this work, and is not responsible for any errors or omissions. The views expressed in this book are those of the author and do not necessarily reflect the views of Oracle. Microsoft and/or its respective suppliers make no representations about the suitability of the information contained in the documents and related graphics published as part of the services for any purpose. All such documents and related graphics are provided "as is" without warranty of any kind. Microsoft
📄 Page
5
and/or its respective suppliers hereby disclaim all warranties and conditions with regard to this information, including all warranties and conditions of merchantability, whether express, implied or statutory, fitness for a particular purpose, title and non-infringement. In no event shall Microsoft and/or its respective suppliers be liable for any special, indirect or consequential damages or any damages whatsoever resulting from loss of use, data or profits, whether in an action of contract, negligence or other tortious action, arising out of or in connection with the use or performance of information available from the services. The documents and related graphics contained herein could include technical inaccuracies or typographical errors. Changes are periodically added to the information herein. Microsoft and/or its respective suppliers may make improvements and/or changes in the product(s) and/or the program(s) described herein at any time. Partial screen shots may be viewed in full within the software version specified. Microsoft® Windows®, and Microsoft Office® are registered trademarks of the Microsoft Corporation in the U.S.A. and other countries. This book is not sponsored or endorsed by or affiliated with the Microsoft Corporation. All rights reserved. This publication is protected by copyright, and permission must be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permissions, request forms and the appropriate contacts within the Pearson Education Global Rights & Permissions Department, please visit pearson.com/en-us/global-permission-granting.html. ISBN-13: 978-0-13-555869-0 ISBN-10: 0-13-555869-7
📄 Page
6
Contents Preface Acknowledgments 1. Streams 1.1. From Iterating to Stream Operations 1.2. Stream Creation 1.3. The filter, map, and flatMap Methods 1.4. Extracting Substreams and Combining Streams 1.5. Other Stream Transformations 1.6. Simple Reductions 1.7. The Optional Type 1.7.1. Getting an Optional Value 1.7.2. Consuming an Optional Value 1.7.3. Pipelining Optional Values 1.7.4. How Not to Work with Optional Values 1.7.5. Creating Optional Values 1.7.6. Composing Optional Value Functions with flatMap 1.7.7. Turning an Optional into a Stream 1.8. Collecting Results 1.9. Collectors 1.9.1. Collecting into Collections 1.9.2. Collecting into Maps 1.9.3. Grouping and Partitioning 1.9.4. Downstream Collectors 1.9.5. Implementing Collectors 1.10. Reduction Operations
📄 Page
7
1.11. Gatherers 1.11.1. Predefined Gatherers 1.11.2. Implementing Gatherers 1.12. Primitive Type Streams 1.13. Parallel Streams 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 Read Text Input 2.1.6. How to Write Text Output 2.1.7. Saving Objects in Text Format 2.1.8. Character Encodings 2.1.9. Default Character Encodings 2.1.10. Reading Character Input 2.2. Reading and Writing Binary Data 2.2.1. The DataInput and DataOutput Interfaces 2.2.2. Random-Access Files 2.2.3. ZIP Archives 2.3. Working with Files 2.3.1. Paths 2.3.2. Reading and Writing Files 2.3.3. Creating Files and Directories 2.3.4. Copying, Moving, and Deleting Files 2.3.5. Getting File Information 2.3.6. Visiting Directory Entries 2.3.7. Glob Patterns
📄 Page
8
2.3.8. Directory Streams 2.3.9. ZIP File Systems 2.4. Memory-Mapped Files 2.4.1. Memory-Mapped File Performance 2.4.2. The Buffer Data Structure 2.5. File Locking 2.6. Object Input/Output Streams and Serialization 2.6.1. Saving and Loading Serializable Objects 2.6.2. Understanding the Object Serialization File Format 2.6.3. Transient Fields 2.6.4. The readObject and writeObject Methods 2.6.5. The readExternal and writeExternal Methods 2.6.6. The readResolve and writeReplace Methods 2.6.7. Versioning 2.6.8. Deserialization and Security 2.6.9. Using Serialization for Cloning 2.7. Regular Expressions 2.7.1. The Regular Expression Syntax 2.7.2. Testing a Match 2.7.3. Finding All Matches in a String 2.7.4. Groups 2.7.5. Splitting along Delimiters 2.7.6. Replacing Matches 2.7.7. Flags 3. XML 3.1. Introducing XML 3.2. The Structure of an XML Document
📄 Page
9
3.3. Parsing an XML Document 3.4. Validating XML Documents 3.4.1. Document Type Definitions 3.4.2. XML Schema 3.4.3. A Practical Example 3.5. Locating Information with XPath 3.6. Using Namespaces 3.7. Streaming Parsers 3.7.1. Using the SAX Parser 3.7.2. Using the StAX Parser 3.8. Generating XML Documents 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 3.9. XSL Transformations 4. Networking 4.1. Connecting to a Server 4.1.1. Using Telnet 4.1.2. Connecting to a Server with 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.2.5. Secure Socket Communication
📄 Page
10
4.3. Getting Web Data 4.3.1. URLs and URIs 4.3.2. Using a URLConnection to Retrieve Information 4.3.3. Posting Form Data 4.4. The HTTP Client 4.4.1. The HttpClient Class 4.4.2. The HttpRequest class and Body Publishers 4.4.3. The HttpResponse Interface and Body Handlers 4.4.4. Asynchronous Processing 4.5. The Simple HTTP Server 4.5.1. The Command-Line Tool 4.5.2. The HTTP Server API 4.5.3. Handlers 4.5.4. Filters 4.6. Sending E-Mail 5. Database Programming 5.1. The Design of JDBC 5.1.1. JDBC Driver Types 5.1.2. Typical Uses of JDBC 5.2. The Structured Query Language 5.3. JDBC Configuration 5.3.1. Database URLs 5.3.2. Driver JAR Files 5.3.3. Starting the Database 5.3.4. Connecting to the Database 5.4. Working with JDBC Statements 5.4.1. Executing SQL Statements
📄 Page
11
5.4.2. Managing Connections, Statements, and Result Sets 5.4.3. Analyzing SQL Exceptions 5.4.4. Populating a Database 5.5. Query Execution 5.5.1. Prepared Statements 5.5.2. Reading and Writing LOBs 5.5.3. SQL Escapes 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 5.9.2. Save Points 5.9.3. Batch Updates 5.9.4. Advanced SQL Types 5.10. Connection Management in Web and Enterprise Applications 6. The Date and Time API 6.1. The Time Line 6.2. Local Dates 6.3. Date Adjusters 6.4. Local Time
📄 Page
12
6.5. Zoned Time 6.6. Formatting and Parsing 6.7. Interoperating with Legacy Code 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. The DecimalFormat Class 7.2.3. 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 7.6. Text Boundaries 7.7. Text Input and Output 7.7.1. Text Files 7.7.2. Line Endings 7.7.3. The Console 7.7.4. The UTF-8 Byte Order Mark 7.7.5. Character Encoding of Source Files 7.8. Resource Bundles 7.8.1. Locating Resource Bundles 7.8.2. Property Files 7.8.3. Bundle Classes
📄 Page
13
7.9. A Complete Example 8. Compiling and Scripting 8.1. The Compiler API 8.1.1. Invoking the Compiler 8.1.2. Launching a Compilation Task 8.1.3. Capturing Diagnostics 8.1.4. Reading Source Files from Memory 8.1.5. Writing Byte Codes to Memory 8.1.6. An Example: Dynamic Java Code Generation 8.2. Scripting for the Java Platform 8.2.1. Getting a Scripting Engine 8.2.2. Script Evaluation and Bindings 8.2.3. Redirecting Input and Output 8.2.4. Calling Scripting Functions and Methods 8.2.5. Compiling a Script 8.2.6. An Example: Script Sheets 9. Security 9.1. Class Loaders 9.1.1. The Class-Loading Process 9.1.2. The Class Loader Hierarchy 9.1.3. Using Class Loaders as Namespaces 9.1.4. Writing Your Own Class Loader 9.1.5. Bytecode Verification 9.2. User Authentication 9.2.1. The JAAS Framework 9.2.2. JAAS Login Modules 9.3. Digital Signatures 9.3.1. Message Digests 9.3.2. Password Hashing
📄 Page
14
9.3.3. Message Signing 9.3.4. Verifying a Signature 9.3.5. The Authentication Problem 9.3.6. Certificate Signing 9.3.7. Code Signing 9.4. Encryption 9.4.1. Symmetric Ciphers 9.4.2. Key Generation 9.4.3. Cipher Streams 9.4.4. Public Key Ciphers 10. Graphical User Interface Programming 10.1. A History of Java User Interface Toolkits 10.2. Displaying Frames 10.2.1. Creating a Frame 10.2.2. Frame Properties 10.3. Displaying Information in a Component 10.3.1. Working with 2D Shapes 10.3.2. Using Color 10.3.3. Using Fonts 10.3.4. Displaying Images 10.4. Event Handling 10.4.1. Basic Event Handling Concepts 10.4.2. Example: Handling a Button Click 10.4.3. Specifying Listeners Concisely 10.4.4. Adapter Classes 10.4.5. Actions 10.4.6. Mouse Events 10.4.7. The AWT Event Hierarchy 10.5. The Preferences API
📄 Page
15
11. User Interface Components with Swing 11.1. Swing and the Model-View-Controller Design Pattern 11.2. Introduction to Layout Management 11.2.1. Layout Managers 11.2.2. Border Layout 11.2.3. Grid Layout 11.3. Text Input 11.3.1. Text Fields 11.3.2. Labels and Labeling Components 11.3.3. Password Fields 11.3.4. Text Areas 11.3.5. Scroll Panes 11.4. Choice Components 11.4.1. Checkboxes 11.4.2. Radio Buttons 11.4.3. Borders 11.4.4. Combo Boxes 11.4.5. Sliders 11.5. Menus 11.5.1. Menu Building 11.5.2. Icons in Menu Items 11.5.3. Checkbox and Radio Button Menu Items 11.5.4. Pop-Up Menus 11.5.5. Keyboard Mnemonics and Accelerators 11.5.6. Enabling and Disabling Menu Items 11.5.7. Toolbars 11.5.8. Tooltips
📄 Page
16
11.6. The Grid Bag Layout 11.6.1. Grid Bag Basics 11.6.2. The gridx, gridy, gridwidth, and gridheight Parameters 11.6.3. Weight Fields 11.6.4. The fill and anchor Parameters 11.6.5. Padding 11.6.6. Alternative Method to Specify the gridx, gridy, gridwidth, and gridheight Parameters 11.6.7. A Grid Bag Layout Recipe 11.6.8. A Helper Class to Tame the Grid Bag Constraints 11.7. Custom Layout Managers 11.8. Dialog Boxes 11.8.1. Option Panes 11.8.2. Creating Dialogs 11.8.3. Data Exchange 11.8.4. File Dialogs 12. Advanced Swing and Graphics 12.1. Tables 12.1.1. A Simple Table 12.1.2. Table Models 12.2. Working with Rows and Columns 12.2.1. Column Classes 12.2.2. Accessing Table Columns 12.2.3. Resizing Columns 12.2.4. Resizing Rows 12.2.5. Selecting Rows, Columns, and Cells 12.2.6. Sorting Rows
📄 Page
17
12.2.7. Filtering Rows 12.2.8. Hiding and Displaying Columns 12.3. Cell Rendering and Editing 12.3.1. Rendering Cells 12.3.2. Rendering the Header 12.3.3. Editing Cells 12.3.4. Custom Editors 12.4. Trees 12.4.1. Simple Trees 12.4.2. Editing Trees and Tree Paths 12.4.3. Node Enumeration 12.4.4. Rendering Nodes 12.4.5. Listening to Tree Events 12.4.6. Custom Tree Models 12.5. Advanced AWT 12.5.1. The Rendering Pipeline 12.5.2. The Shape Class Hierarchy 12.5.3. Constructing Shapes 12.5.4. Areas 12.5.5. Strokes 12.5.6. Paint 12.5.7. Coordinate Transformations 12.5.8. Clipping 12.5.9. Transparency and Composition 12.6. Raster Images 12.6.1. Readers and Writers for Images 12.6.2. Obtaining Readers and Writers for Image File Types
📄 Page
18
12.6.3. Reading and Writing Files with Multiple Images 12.6.4. Image Manipulation 12.6.5. Filtering Images 12.7. Printing 12.7.1. Graphics Printing 12.7.2. Multiple-Page Printing 12.7.3. Print Services 12.7.4. Stream Print Services 12.7.5. Printing Attributes 13. The Foreign Functions and Memory API 13.1. Using JNI to Call C Code from a Java Program 13.2. Using FFM to Call a Foreign Function 13.3. Arenas 13.4. Memory Segments 13.5. Memory Layout 13.6. Looking Up and Invoking Foreign Functions 13.7. Callbacks 13.8. Advanced Topics 13.8.1. Accessing Memory With Variable Handles 13.8.2. Calling a Foreign Varargs Function 13.8.3. Capturing errno Index
📄 Page
19
Preface To the Reader The book you have in your hands is the second volume of the thirteenth edition of Core Java, fully updated for Java 25. The first volume covers the essential features of the language; this volume deals with the advanced topics that a programmer needs to know for professional software development. Thus, as with the first volume and the previous editions of this book, we are still targeting programmers who want to put Java technology to work in real projects. With the explosive growth of the Java class library, a one- volume treatment of all the features of Java that serious programmers need to know is simply not possible. Hence, the book is broken up into two volumes. This first volume concentrates on the fundamental concepts of the Java language: Object-oriented programming Reflection and proxies Interfaces and inner classes Exception handling Generic programming The collections framework Concurrency
📄 Page
20
Annotations The Java platform module system This second volume goes further into the most important libraries. For twelve editions, user interface programming was considered fundamental, but the time has come to recognize that it is no more, and to move it into the second volume. The volume includes detailed discussions of these topics: The Stream API File processing and regular expressions Databases XML processing Scripting and Compiling APIs Internationalization Network programming Graphical user interface design Graphics programming Foreign functions and memory As is the case with any book, errors and inaccuracies are inevitable. Should you find any in this book, we would very much like to hear about them. Of course, we would prefer to hear about them only once. For this reason, we have put up a web site at https://horstmann.com/corejava with a FAQ, bug fixes, and workarounds. Strategically placed at the end of the bug report web page (to encourage you to read the previous reports) is a form that you can use to report
The above is a preview of the first 20 pages. Register to read the complete e-book.
Recommended for You
Loading recommended books...
Failed to load, please try again later