Core Java, Volume II--Advanced Features

Book description

The #1 Guide to Advanced Java Programming, Fully Updated for Java 11

Core Java has long been recognized as the leading, no-nonsense tutorial and reference for experienced programmers who want to write robust Java code for real-world applications. Now, Core Java, Volume II—Advanced Features, Eleventh Edition, has been updated for Java 11, with up-to-date coverage of advanced UI and enterprise programming, networking, security, and Java’s powerful new module system.

Cay S. Horstmann explores sophisticated new language and library features with the depth and completeness that readers expect from Core Java. He demonstrates how to use these features to build professional-quality applications, using thoroughly tested examples that reflect modern Java style and best practices, including modularization. Horstmann’s examples are carefully crafted for easy understanding and maximum practical value, so you can consistently use them to jump-start your own code.

  • Master advanced techniques, idioms, and best practices for writing superior Java code

  • Take full advantage of modern Java I/O APIs, object serialization, and regular expressions

  • Efficiently connect to network services, implement network clients and servers, and harvest web data

  • Query databases and manage database connections with the latest version of JDBC

  • Simplify all aspects of date and time programming with the Java Date and Time API

  • Write internationalized programs that localize dates, times, numbers, text, and GUIs

  • Process code in three powerful ways: the scripting API, compiler API, and annotation processing

  • Learn how to migrate legacy code to the Java Platform Module System

  • Leverage the modern Java security features most valuable to application programmers

  • Program advanced client-side user interfaces, and generate images on the server

  • Use JNI to interoperate with native C code

See Core Java, Volume I—Fundamentals, Eleventh Edition (ISBN-13: 978-0-13-516630-7), for expert coverage of fundamental Java and UI programming, including objects, generics, collections, lambda expressions, Swing design, concurrency, and functional programming.

Register your book for convenient access to downloads, updates, and/or corrections as they become available. See inside book for details.

Table of contents

  1. Cover Page
  2. Title Page
  3. Copyright Page
  4. Contents
  5. Preface
  6. Acknowledgments
  7. Chapter 1: Streams
    1. 1.1 From Iterating to Stream Operations
    2. 1.2 Stream Creation
    3. 1.3 The filter, map, and flatMap Methods
    4. 1.4 Extracting Substreams and Combining Streams
    5. 1.5 Other Stream Transformations
    6. 1.6 Simple Reductions
    7. 1.7 The Optional Type
      1. 1.7.1 Getting an Optional Value
      2. 1.7.2 Consuming an Optional Value
      3. 1.7.3 Pipelining Optional Values
      4. 1.7.4 How Not to Work with Optional Values
      5. 1.7.5 Creating Optional Values
      6. 1.7.6 Composing Optional Value Functions with flatMap
      7. 1.7.7 Turning an Optional into a Stream
    8. 1.8 Collecting Results
    9. 1.9 Collecting into Maps
    10. 1.10 Grouping and Partitioning
    11. 1.11 Downstream Collectors
    12. 1.12 Reduction Operations
    13. 1.13 Primitive Type Streams
    14. 1.14 Parallel Streams
  8. Chapter 2: Input and Output
    1. 2.1 Input/Output Streams
      1. 2.1.1 Reading and Writing Bytes
      2. 2.1.2 The Complete Stream Zoo
      3. 2.1.3 Combining Input/Output Stream Filters
      4. 2.1.4 Text Input and Output
      5. 2.1.5 How to Write Text Output
      6. 2.1.6 How to Read Text Input
      7. 2.1.7 Saving Objects in Text Format
      8. 2.1.8 Character Encodings
    2. 2.2 Reading and Writing Binary Data
      1. 2.2.1 The DataInput and DataOutput interfaces
      2. 2.2.2 Random-Access Files
      3. 2.2.3 ZIP Archives
    3. 2.3 Object Input/Output Streams and Serialization
      1. 2.3.1 Saving and Loading Serializable Objects
      2. 2.3.2 Understanding the Object Serialization File Format
      3. 2.3.3 Modifying the Default Serialization Mechanism
      4. 2.3.4 Serializing Singletons and Typesafe Enumerations
      5. 2.3.5 Versioning
      6. 2.3.6 Using Serialization for Cloning
    4. 2.4 Working with Files
      1. 2.4.1 Paths
      2. 2.4.2 Reading and Writing Files
      3. 2.4.3 Creating Files and Directories
      4. 2.4.4 Copying, Moving, and Deleting Files
      5. 2.4.5 Getting File Information
      6. 2.4.6 Visiting Directory Entries
      7. 2.4.7 Using Directory Streams
      8. 2.4.8 ZIP File Systems
    5. 2.5 Memory-Mapped Files
      1. 2.5.1 Memory-Mapped File Performance
      2. 2.5.2 The Buffer Data Structure
    6. 2.6 File Locking
    7. 2.7 Regular Expressions
      1. 2.7.1 The Regular Expression Syntax
      2. 2.7.2 Matching a String
      3. 2.7.3 Finding Multiple Matches
      4. 2.7.4 Splitting along Delimiters
      5. 2.7.5 Replacing Matches
  9. Chapter 3: XML
    1. 3.1 Introducing XML
    2. 3.2 The Structure of an XML Document
    3. 3.3 Parsing an XML Document
    4. 3.4 Validating XML Documents
      1. 3.4.1 Document Type Definitions
      2. 3.4.2 XML Schema
      3. 3.4.3 A Practical Example
    5. 3.5 Locating Information with XPath
    6. 3.6 Using Namespaces
    7. 3.7 Streaming Parsers
      1. 3.7.1 Using the SAX Parser
      2. 3.7.2 Using the StAX Parser
    8. 3.8 Generating XML Documents
      1. 3.8.1 Documents without Namespaces
      2. 3.8.2 Documents with Namespaces
      3. 3.8.3 Writing Documents
      4. 3.8.4 Writing an XML Document with StAX
      5. 3.8.5 An Example: Generating an SVG File
    9. 3.9 XSL Transformations
  10. Chapter 4: Networking
    1. 4.1 Connecting to a Server
      1. 4.1.1 Using Telnet
      2. 4.1.2 Connecting to a Server with Java
      3. 4.1.3 Socket Timeouts
      4. 4.1.4 Internet Addresses
    2. 4.2 Implementing Servers
      1. 4.2.1 Server Sockets
      2. 4.2.2 Serving Multiple Clients
      3. 4.2.3 Half-Close
      4. 4.2.4 Interruptible Sockets
    3. 4.3 Getting Web Data
      1. 4.3.1 URLs and URIs
      2. 4.3.2 Using a URLConnection to Retrieve Information
      3. 4.3.3 Posting Form Data
    4. 4.4 The HTTP Client
    5. 4.5 Sending E-Mail
  11. Chapter 5: Database Programming
    1. 5.1 The Design of JDBC
      1. 5.1.1 JDBC Driver Types
      2. 5.1.2 Typical Uses of JDBC
    2. 5.2 The Structured Query Language
    3. 5.3 JDBC Configuration
      1. 5.3.1 Database URLs
      2. 5.3.2 Driver JAR Files
      3. 5.3.3 Starting the Database
      4. 5.3.4 Registering the Driver Class
      5. 5.3.5 Connecting to the Database
    4. 5.4 Working with JDBC Statements
      1. 5.4.1 Executing SQL Statements
      2. 5.4.2 Managing Connections, Statements, and Result Sets
      3. 5.4.3 Analyzing SQL Exceptions
      4. 5.4.4 Populating a Database
    5. 5.5 Query Execution
      1. 5.5.1 Prepared Statements
      2. 5.5.2 Reading and Writing LOBs
      3. 5.5.3 SQL Escapes
      4. 5.5.4 Multiple Results
      5. 5.5.5 Retrieving Autogenerated Keys
    6. 5.6 Scrollable and Updatable Result Sets
      1. 5.6.1 Scrollable Result Sets
      2. 5.6.2 Updatable Result Sets
    7. 5.7 Row Sets
      1. 5.7.1 Constructing Row Sets
      2. 5.7.2 Cached Row Sets
    8. 5.8 Metadata
    9. 5.9 Transactions
      1. 5.9.1 Programming Transactions with JDBC
      2. 5.9.2 Save Points
      3. 5.9.3 Batch Updates
      4. 5.9.4 Advanced SQL Types
    10. 5.10 Connection Management in Web and Enterprise Applications
  12. Chapter 6: The Date and Time API
    1. 6.1 The Time Line
    2. 6.2 Local Dates
    3. 6.3 Date Adjusters
    4. 6.4 Local Time
    5. 6.5 Zoned Time
    6. 6.6 Formatting and Parsing
    7. 6.7 Interoperating with Legacy Code
  13. Chapter 7: Internationalization
    1. 7.1 Locales
      1. 7.1.1 Why Locales?
      2. 7.1.2 Specifying Locales
      3. 7.1.3 The Default Locale
      4. 7.1.4 Display Names
    2. 7.2 Number Formats
      1. 7.2.1 Formatting Numeric Values
      2. 7.2.2 Currencies
    3. 7.3 Date and Time
    4. 7.4 Collation and Normalization
    5. 7.5 Message Formatting
      1. 7.5.1 Formatting Numbers and Dates
      2. 7.5.2 Choice Formats
    6. 7.6 Text Input and Output
      1. 7.6.1 Text Files
      2. 7.6.2 Line Endings
      3. 7.6.3 The Console
      4. 7.6.4 Log Files
      5. 7.6.5 The UTF-8 Byte Order Mark
      6. 7.6.6 Character Encoding of Source Files
    7. 7.7 Resource Bundles
      1. 7.7.1 Locating Resource Bundles
      2. 7.7.2 Property Files
      3. 7.7.3 Bundle Classes
    8. 7.8 A Complete Example
  14. Chapter 8: Scripting, Compiling, and Annotation Processing
    1. 8.1 Scripting for the Java Platform
      1. 8.1.1 Getting a Scripting Engine
      2. 8.1.2 Script Evaluation and Bindings
      3. 8.1.3 Redirecting Input and Output
      4. 8.1.4 Calling Scripting Functions and Methods
      5. 8.1.5 Compiling a Script
      6. 8.1.6 An Example: Scripting GUI Events
    2. 8.2 The Compiler API
      1. 8.2.1 Invoking the Compiler
      2. 8.2.2 Launching a Compilation Task
      3. 8.2.3 Capturing Diagnostics
      4. 8.2.4 Reading Source Files from Memory
      5. 8.2.5 Writing Byte Codes to Memory
      6. 8.2.6 An Example: Dynamic Java Code Generation
    3. 8.3 Using Annotations
      1. 8.3.1 An Introduction into Annotations
      2. 8.3.2 An Example: Annotating Event Handlers
    4. 8.4 Annotation Syntax
      1. 8.4.1 Annotation Interfaces
      2. 8.4.2 Annotations
      3. 8.4.3 Annotating Declarations
      4. 8.4.4 Annotating Type Uses
      5. 8.4.5 Annotating this
    5. 8.5 Standard Annotations
      1. 8.5.1 Annotations for Compilation
      2. 8.5.2 Annotations for Managing Resources
      3. 8.5.3 Meta-Annotations
    6. 8.6 Source-Level Annotation Processing
      1. 8.6.1 Annotation Processors
      2. 8.6.2 The Language Model API
      3. 8.6.3 Using Annotations to Generate Source Code
    7. 8.7 Bytecode Engineering
      1. 8.7.1 Modifying Class Files
      2. 8.7.2 Modifying Bytecodes at Load Time
  15. Chapter 9: The Java Platform Module System
    1. 9.1 The Module Concept
    2. 9.2 Naming Modules
    3. 9.3 The Modular “Hello, World!” Program
    4. 9.4 Requiring Modules
    5. 9.5 Exporting Packages
    6. 9.6 Modular JARs
    7. 9.7 Modules and Reflective Access
    8. 9.8 Automatic Modules
    9. 9.9 The Unnamed Module
    10. 9.10 Command-Line Flags for Migration
    11. 9.11 Transitive and Static Requirements
    12. 9.12 Qualified Exporting and Opening
    13. 9.13 Service Loading
    14. 9.14 Tools for Working with Modules
  16. Chapter 10: Security
    1. 10.1 Class Loaders
      1. 10.1.1 The Class-Loading Process
      2. 10.1.2 The Class Loader Hierarchy
      3. 10.1.3 Using Class Loaders as Namespaces
      4. 10.1.4 Writing Your Own Class Loader
      5. 10.1.5 Bytecode Verification
    2. 10.2 Security Managers and Permissions
      1. 10.2.1 Permission Checking
      2. 10.2.2 Java Platform Security
      3. 10.2.3 Security Policy Files
      4. 10.2.4 Custom Permissions
      5. 10.2.5 Implementation of a Permission Class
    3. 10.3 User Authentication
      1. 10.3.1 The JAAS Framework
      2. 10.3.2 JAAS Login Modules
    4. 10.4 Digital Signatures
      1. 10.4.1 Message Digests
      2. 10.4.2 Message Signing
      3. 10.4.3 Verifying a Signature
      4. 10.4.4 The Authentication Problem
      5. 10.4.5 Certificate Signing
      6. 10.4.6 Certificate Requests
      7. 10.4.7 Code Signing
    5. 10.5 Encryption
      1. 10.5.1 Symmetric Ciphers
      2. 10.5.2 Key Generation
      3. 10.5.3 Cipher Streams
      4. 10.5.4 Public Key Ciphers
  17. Chapter 11: Advanced Swing and Graphics
    1. 11.1 Tables
      1. 11.1.1 A Simple Table
      2. 11.1.2 Table Models
      3. 11.1.3 Working with Rows and Columns
        1. 11.1.3.1 Column Classes
        2. 11.1.3.2 Accessing Table Columns
        3. 11.1.3.3 Resizing Columns
        4. 11.1.3.4 Resizing Rows
        5. 11.1.3.5 Selecting Rows, Columns, and Cells
        6. 11.1.3.6 Sorting Rows
        7. 11.1.3.7 Filtering Rows
        8. 11.1.3.8 Hiding and Displaying Columns
      4. 11.1.4 Cell Rendering and Editing
        1. 11.1.4.1 Rendering Cells
        2. 11.1.4.2 Rendering the Header
        3. 11.1.4.3 Editing Cells
        4. 11.1.4.4 Custom Editors
    2. 11.2 Trees
      1. 11.2.1 Simple Trees
        1. 11.2.1.1 Editing Trees and Tree Paths
      2. 11.2.2 Node Enumeration
      3. 11.2.3 Rendering Nodes
      4. 11.2.4 Listening to Tree Events
      5. 11.2.5 Custom Tree Models
    3. 11.3 Advanced AWT
      1. 11.3.1 The Rendering Pipeline
      2. 11.3.2 Shapes
        1. 11.3.2.1 The Shape Class Hierarchy
        2. 11.3.2.2 Using the Shape Classes
      3. 11.3.3 Areas
      4. 11.3.4 Strokes
      5. 11.3.5 Paint
      6. 11.3.6 Coordinate Transformations
      7. 11.3.7 Clipping
      8. 11.3.8 Transparency and Composition
    4. 11.4 Raster Images
      1. 11.4.1 Readers and Writers for Images
        1. 11.4.1.1 Obtaining Readers and Writers for Image File Types
        2. 11.4.1.2 Reading and Writing Files with Multiple Images
      2. 11.4.2 Image Manipulation
        1. 11.4.2.1 Constructing Raster Images
        2. 11.4.2.2 Filtering Images
    5. 11.5 Printing
      1. 11.5.1 Graphics Printing
      2. 11.5.2 Multiple-Page Printing
      3. 11.5.3 Print Services
      4. 11.5.4 Stream Print Services
      5. 11.5.5 Printing Attributes
  18. Chapter 12: Native Methods
    1. 12.1 Calling a C Function from a Java Program
    2. 12.2 Numeric Parameters and Return Values
    3. 12.3 String Parameters
    4. 12.4 Accessing Fields
      1. 12.4.1 Accessing Instance Fields
      2. 12.4.2 Accessing Static Fields
    5. 12.5 Encoding Signatures
    6. 12.6 Calling Java Methods
      1. 12.6.1 Instance Methods
      2. 12.6.2 Static Methods
      3. 12.6.3 Constructors
      4. 12.6.4 Alternative Method Invocations
    7. 12.7 Accessing Array Elements
    8. 12.8 Handling Errors
    9. 12.9 Using the Invocation API
    10. 12.10 A Complete Example: Accessing the Windows Registry
      1. 12.10.1 Overview of the Windows Registry
      2. 12.10.2 A Java Platform Interface for Accessing the Registry
      3. 12.10.3 Implementation of Registry Access Functions as Native Methods
  19. Index
  20. Credits
  21. Code Snippets

Product information

  • Title: Core Java, Volume II--Advanced Features
  • Author(s): Cay S. Horstmann
  • Release date: July 2018
  • Publisher(s): Addison-Wesley Professional
  • ISBN: 9780135167175