所需积分/C币:10 2014-04-08 17:01:42 51.26MB PDF
收藏 收藏

英文第九版完整版,不看二手货,不解释。 Core Java, Volume II-Advanced Features (9th Edition).pdf Java核心技术·卷2:高级特征(原书第9版)
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 ini tial capital letters or in al capitals Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners The authors 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 This document is provided for information purposes only and the contents hereof are subject to change without notice. This document is not warranted to be error-free, nor subject to any other warranties or conditions, whether expressed orally or implied in law, including implied warranties and conditions of merchantability or fitness for a particular purpose. We specifically disclaim any liability with respect to this document and no contractual obligations are formed either directly or indirectly by this document. This document may not be reproduced or transmitted in any form or by any means, electronic or mechanical, for any purpose, without our prior written permission The publisher offers excellent discounts on this book when ordered in quantity for bulk purchases or special sales, which may include electronic versions and/or custom covers and content particular to your business, training goals, marketing focus, and branding interests. For more information, please contact U.S. Corporate and Government Sales 800)3823419 For sales outside the United States, please contact: International sales Visit us on the Web: informit. com/ph Library of Congress Cataloging-in-Publication Data Horstmann, Cay S, 1959- Core Java/ cay s. Horstmann gary corne l -Ninth edition pages cm Includes index ISBN 978-0-13-708189-9(v 1: pbk: alk. paper)1. Java (Computer progr language)L. Cornell, Gary. Il. Title QA76.73J38H67532013 005.133-dc23 2012035397 Copyright o 2013 Oracle and/or its affiliates. All rights reserved 500 Oracle Parkway, Redwood shores, CA 94065 Printed in the United States of America. 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, photo copying recording, or likewise. To obtain permission to use material from this work, please submit a written request to Pearson Education, Inc Permissions Department, One Lake Street, Upper Saddle River, New Jersey 07458, or you may fax your request to(201)236-3290 sBN-13:9780-13-708160-8 ISBN-10 0-13-708160-X Text printed in the United states on recycled paper at Edwards Brothers Malloy in Ann Arbor, michigan First printing, February 2013 Contents Preface Acknowedgments Chapter 1: Streams and Files 1.1 Streams 1.1.1 Reading and writing byte 1.1.2 The Complete Stream Zoo 1.1.3 Combining stream Filters 1.2 Text Input and Output 1.2. 1 How to Write Text Output 1.2. 2 How to Read text Input 1.2. 3 Saving obiects in Text Format 1.2 4 Character sets 1.3 Reading and Writing binary data 1.3.1 Random-Access files 1.4 ZP Archives 1.5 Object Streams and Serialization 1.5. 1 Understanding the obiect Serialization File format 1.5.2 Modifying the Default Serialization Mechanism 1.5.3 Serializing singletons and Typesafe Enumerations 1.5. 4 Versioning 1.5.5 Using Serialization for Cloning. 1.6 Working with Files 1.6.1 Paths 1.6.2 Reading and writing Files 1.6.3 Copying, Moving, and Deleting Files 1.6. 4 Creating Files and Directories 1.6.5 Getting File Information 1.6.6 iterating over the Files in a Directory 1.6.7 ZIP File Systems 1.7 Memory-Mapped Files 17.1 The Buffer data structure 1.7.2 File Locking 1.8 Regular Expressions Chapter 2: XML 2. 1 Introducing XML 2.1.1 The Structure of an Xml document 2.2 Parsing an XML Document 2.3 Validating XML Documents 2.3.1 Document Type Definitions 2.3.2 XML Schema 2.3.3 A Practical Example 2.4 Locating Information with XPath 2.5 Using Namespaces 2.6 Streaming Parsers 2.6. 1 Using the SAX Parser 2.6.2 Using the StAX Parser 2.7 Generating XML Documents 2.7. 1 Documents without Namespaces 2.7.2 Documents with Namespaces 2.7.3 Writing Documents 2.7.4 An Example: Generating an SVG File 2.7.5 Writing an XML Document with StAX 2.8 XSL Transformations Chapter 3: Networking 3.1 Connecting to a Sen 3.1.1 Socket Timeouts 3.1.2 Intemet Addresses 3.2 Implementing Servers 3.2.1 Serving Multiple Clients 3.2.2 Half-Close 3.3 Interruptible Sockets 3.4 Getting Web data 3. 4. 1 URLs and Uris 3.4.2 Using a UR-Connect ion to Retrieve Information 3.4.3 Posting Form Data 3.5 Sending E-Mail Chapter 4: Database Programming 4.1 The Design of JDBc 4.1.1 JDBC Driver Types 4.1.2 Typical Uses of JDBC 4.2 The Structured Query Language 4.3 JDBC Configuration 43.1 Database urls 4.3.2 Driver jar Files 4.3.3 Starting the Database 4.3. 4 Registering the Driver Class 4.3.5 Connecting to the Database 4.4 EXecuting sQL Statements 4. 4. 1 Managing Connections, Statements, and Result Sets 4.4.2 Analyzing sQL EXceptions 4.4.3 Populating a Database 4.5 Query Execution 4.5. 1 Prepared statements 4.5.2 Reading and Writing LOBs 4.5.3 SQL Escapes 4.5.4 Multiple Results 4.5.5 Retrieving Autogenerated Keys 4.6 Scrollable and Updatable Result Sets 4.6.1 Scrollable result sets 4.6.2 Updatable Result Sets 4.7 Row Sets 4.7.1 Constructing Row Sets 47.2 Cached row sets 4.8 Metadata 4.9 Transactions 4.9.1 Save points 4.9.2 Batch Updates 4.9.3 Advanced SQL Types 4.10 Connection Management in Web and Enterprise Applications Chapter 5: Internationalization 5.1 Locales 5.2 Number formats 5.2.1 Currencies 5.3 Date and time 5. 4 Collation 5.4.1 Collation Strength 5.4.2 Decomposition 5.5 Message Formatti 5.5.1 Choice formats 5.6 Text Files and character sets 5.6. 1 Character Encoding of source Files 5.7 Resource bundles 5.7.1 Locating Resource Bundles 5.7. 2 Property Files 5.7. 3 Bundle classes 5.8 A Complete EⅪampl Chapter 6: Advanced Swing 6.1 Lists 6.1.1 The JList Component 6.1.2 List models 6.1.3 Inserting and Removing values 6.1. 4 Rendering values 6.2 Tables 6.2.1A Simple Table 6.2.2 Table models 6.2.3 Working with Rows and columns Column classes Accessing Table Columns Resizing columns 6.2.3 4 Resizing Rows Selecting Rows, Columns, and Cells Sorting Rows Filtering Rows 6.2.3. 8 Hiding and Displaying columns 6.2. 4 Cell Rendering and Editing Rendering the Header 624.2ce‖ Editin 6.24.3 CuStom Editors 6.3 Trees 6.3. 1 Simple Trees 6.3.1. 1 Editing Trees and Tree Paths 6.3.2 Node enumeration 6.3.3 Rendering Nodes 6.3. 4 Listening to Tree Events 6.3.5 Custom tree models 6.4 Text Components 6.4.1 Change Tracking in Text Components 6.4.2 Formatted Input Fields Integer Input Behavior on Loss of Focus 6.4.23 Filters Verifiers 6.4.25 other standard formatters Custom formatters 6.4.3 The JSpinncr Component 6.4.4 Displaying HTMl with the jeditorparc 6.5 Progress Indicators 6.5. 1 Progress Bars 6.5.2 Progress Monitors 6.5.3 Monitoring the Progress of Input Streams 6.6 Component Organizers and decorators 6.6.1 Split Panes 6.6.2 Tabbed panes 6.6.3 Desktop Panes and Internal Frames 6.6. 4 Cascading and Til 6.6.5 Vetoing Property Settings 6.6.5. 1 Dialogs in Internal Frames Outline Dragging 6.6.6.lAyers Chapter 7: Advanced AWT 7.1 The Rendering pipeline. 7.2 Shapes 7.2. 1 Using the Shape Classes 7. 3 Area 7. 4 Strokes 7.5 Paint 7.6 Coordinate Transformations 7.7 Clipping 1.8 Transparency and composition 7.9 Rendering Hints 7.10 Readers and Writers for Images 7.10. 1 Obtaining Readers and Writers for Image File Types 7.10.2 Reading and Writing Files with Multiple Images 7. 11 Image Manipulation 7. 11. 1 Constructing raster Images 7.11.2 Filtering Images 7.12 Printing. 7. 12.1 Graphics Printing. 7.12.2 Multiple-Page Printing 7.123 Print preview 7.124 Print services 7.125 Stream Print services 7.12.6 Printing Attributes 7.13 The Clipboard 7.13.1 Classes and Interfaces for data transfer 7.13.2 Transferring Text 7.13.3 The transferable Interface and data Flavors 7. 13. 4 Building an Image Transferable 7. 13.5 Transferring Java Obiects via the System Clipboard 7. 13.6 Using a Local clipboard to Transfer Object References 7.14 Drag and Drop 1. 14.1 Data Transfer Support in Swing 7.14.2 Drag Sources 7.14.3 Drop Targets 7.15 Platform Integration 7. 15.1 Splash Screens 7. 15.2 Launching Desktop Applications 7. 15.3 The System Tra Chapter 8: JavaBeans Components 8. 1 Why beans? 8.2 The Bean-Writing Process 8.3 Using Beans to Build an Application 8. 3. 1 Packaging Beans in JAR Files 8.3.2 Composing Beans in a Builder environment 8. 4 Naming Patterns for Bean Properties and Events 8.5 Bean Property Types 8.5. 1 Simple Properties 8.5.2 Indexed Properties 8.5.3 Bound Properties 8.5. 4 Constrained Properties. 8.6 Beaner± o classes 8.7 Property Editors 8.7. 1 Writing property editors 8.7.1. 1 String-Based Property Editors GUFBased Property Editors 8. 8 Customizers 8.8.1 Writing a Customizer Class 8.9 Java Beans persistence 8.9. 1 Using Java Beans Persistence for Arbitrary Data 8.9. 1.1 Writing a persistence Delegate to Construct an obiect Constructing an obiect from Properties 8. 9.1.3 Constructing an obiect with a Factory Method 8. 9.1.4 Postconstruction Work Transient Properties 8.9. A Complete Example for JavaBeans Persistence Chapter 9: Security 9.1 Class Loaders 9.1.1 The Class Loader Hierarchy 9.1.2 Using Class Loaders as Namespaces 9.1.3 Writing Your Own Class Loader 9.2 BYtecode verification 9.3 Security Managers and permissions 9.3.1 Java Platform Security 9.3.2 Security Policy Files 9.3.3 Custom permissions 9.3. 4 Implementation of a Permission Class 9. 4 User Authentication 9.4.1 JAAS Login Modules 9.5 Digital Signatures 9.5. 1 Message Digests 9.5.2 Message Signing. 9.5.3 Verifying a signature 9.5. 4 The authentication problem 9.5.5 Certificate Signing. 9.5.6 Certificate Requests 9.6 Code Signing 9.6.1 JAR File signing 9.6.2 Software Developer Certificates 9.7 Encryption 9.7.1 Symmetric Cipher 9.7.2 Key Generation 9.7.3 Cipher Streams 9.7. 4 Public Key ciphers Chapter 10: Scripting. Compiling, and Annotation Processing 10.1 Scripting for the Java Platform 10.1.1 Getting a Scripting Engine 10.1.2 Script Evaluation and Bindings 10.1.3 Redirecting Input and output 10.1. 4 Calling Scripting Functions and Methods 10.1.5 Compiling a Script 10.1.6 An Example: Scripting gul Events 10.2 The Compiler API 10.2.1 Compiling the easy Way 10.2.2 Using Compilation Tasks 10.2.3 An Example: Dynamic Java Code Generation 10.3 Using Annotations 10.3. 1 An Example: Annotating Event Handlers 10. 4 Annotation Syntax 10.5 Standard Annotations 10.5. 1 Annotations for Compilation 10.5.2 Annotations for Managing resources 10.5.3 Meta-Annotations 10.6 Source-Level Annotation Processing 10.7 BYtecode Engineering 10.7.1 Moditying Bytecodes at Load Time Chapter 11: Distributed objects 11.1 the roles of c lient and server 11.2 Remote method calls 11.2. 1 Stubs and Parameter Marshalling 11. 3 The RM Programming model 11.3. 1 Interfaces and Implementations 11.3.2 The RMi Registry 11.3.3 Deploying the program 11.3. 4 Logging rMi activity 11.4 Parameters and return values in remote methods 11.4.1 Transferring Remote Objects 11.4.2 Transferring Nonremote Objects 11.4.3 Dynamic Class Loading 11. 4. 4 Remote References with Multiple Interfaces 11.4.5 Remote obiects and the equals, hashCode, and clone methods 11.5 Remote Obiect Activation Chapter 12: Native Methods 12.1 Calling a C Function from a Java Program 12.2 Numeric Parameters and return values 12.2.1 Using pr f for Formatting Numbers 12.3 String Parameters 12.4 Accessing Fields 12. 4.1 Accessing Instance Fields 12.4.2 Accessing Static Fields 12.5 Encoding signatures 12.6 Calling java Methods 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 Hand ling errors 12.9 Using the Invocation APl 12.10 A Complete Example: Accessing the Windows Registry 12.10. 1 Overview of the Windows Registry 12.10.2 A Java Platform Interface for Accessing the Registry 12.10.3 Implementation of Registry Access Functions as Native Methods Index Preface To the reader The book you have in your hands is the second volume of the ninth edition of Core Javal), fully updated for Java SE 7. 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 on real projects Please note If you are an experienced developer who is comfortable with advanced language features such as inner classes and generics, you need not have read the first volume in order to benefit from this volume. While we do refer to sections of the previous volume when appropriate (and, of course, hope you will buy or have bought Volume I), you can find all the background material you need in any comprehensive introductor book about the Java platform Finally, 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 with a FAQ, bug fixes, and workarounds. Strategically placed at the end of the bug report web page(to encourage you to read the previollo java aboutthemOfcoursewewouldprefertohearaboutthemonlyonceForthisreasonwehaveputupawebsiteat reports)is a form that you can use to report bugs or problems and to send suggestions for improvements to future editions About this book The chapters in this book are, for the most part, independent of each other. You should be able to delve into whatever topic interests you the most and read the chapters in any order The topic of chapter 1 is input and output handling(VO). In Java, all VO is handled through so-called streams. Streams let you deal, in a uniform manner, with communications among various sources of data, such as files, network connections, or memory blocks. We include detailed coverage of the reader and writer classes that make it easy to deal with Unicode We show you what goes on under the hood when you use the object serialization mechanism, which makes saving and loading objects easy and convenient. We then move on to regular expressions and the NIO2 library of Java SE 7, which makes common operations(such as reading all lines in a file)very convenient. Chapter 2 covers XML. We show you how to parse XML files, how to generate XML, and how to use XSL transformations As a useful example we show you how to specify the layout of a Swing form in XML. We also discuss the XPath APl, which makes"finding needles in XML haystacks much easier Chapter 3 covers the networking APl. Java makes it phenomenally easy to do complex network programming We show you how to make network connections to servers how to implement your own servers and how to make Http connections Chapter 4 covers database programming. The main focus is on JDBC, the Java database connectivity aPi that lets Java programs connect to relational databases. We show you how to write useful programs to handle realistic database chores, using a core subset of the JDBC API.(A complete treatment of the JDBC API would require a book almost as long as this one We finish the chapter with a brief introduction into hierarchical databases and discuss JNDi (the Java Naming and Directory Interface )and LdaP (the Lightweight Directory Access Protocol) Chapter 5 discusses a feature that we believe can only grow in importance: internationalization. the Java programming language is one of the few languages designed from the start to handle Unicode, but the internationalization support in the Java platform goes much further. As a result, you can internationalize Java applications so that they not only cross platforms but cross country boundaries as well. For example, we show you how to write a retirement calculator that uses either English, German, or Chinese languages Chapter 6 contains all the Swing material that didn t make it into Volume l, especially the important but complex tree and table components. We show the basic uses of editor panes, the Java implementation of a"multiple document interface, progress indicators used in multithreaded programs, and" desktop integration features"such as splash screens and support for the system tray. Again, we focus on the most useful constructs that you are likely to encounter in practical programming because an encyclopedic coverage of the entire Swing library would fill several volumes and would only be of interest to dedicated taxonomists Chapter 7 covers the Java 2D APL, which you can use to create realistic drawings and special effects the chapter also covers some advanced features of the AWT(Abstract Windowing Toolkit) that seemed too specialized for coverage in Volume I but should, nonetheless, be part of every programmer's toolkit. These features include printing and the APIs for cut-and-paste and drag-and-drop Chapter 8 explains what you need to know about the component aPi for the Java platform--JavaBeans. We show you how to write your own beans that other programmers can manipulate in integrated builder environments We conclude this chapter by showing you how you can use Java beans persistence to store your data in a format that-unlike object serialization-is suitable for long-term storage applications. Then, we take up the security API that allows for such important features as message and code signing, authorization any urpose r Chapter 9 takes up the Java security model. The Java platform was designed from the ground up to be secure, and this chapter takes you under the hood to see how this design is implemented. We show you how to write your own class loaders and security managers for special-pi authentication, and encryption. We conclude with examples that use the aeS and RSA encryption algorithms Chapter 10 covers distributed objects. We cover RMI (Remote Method Invocation)in detail. This aPI lets you work with Java objects that are distributed over multiple machines Chapter 11 discusses three techniques for processing code. The scripting and compiler aPis allow your program to call code in scripting languages such as Java Script or Groovy, and to compile Java code Annotations allow you to add arbitrary information(sometimes called metadata to a Java program. We show you how annotation processors can harvest these annotations at the source or class file level, and how annotations can be used to influence the behavior of classes at runtime. Annotations are only useful with tools, and we hope that our discussion will help you select useful annotation processing tools for your needs Chapter 12 takes up native methods, which let you call methods written for a specific machine such as the Microsoft Windows APl. Obviously, this feature is controversial: Use native methods, and the cross-platform nature of the Java platform vanishes. None theless, every serious programmer writing Java applications for specific platforms needs to know these techniques. At times, you need to turn to the operating system's aPI for your target platform when you interact with a device or service that is not supported by Java. We illustrate this by showing you how to access the registry APl in Windows from a Java program As always, all chapters have been completely revised for the latest version of Java. Outdated material has been removed, and the new AP Is of Java se 7 are covered in detail Conventions

试读 127P Java核心技术(卷2):高级特性(原书第9版)
立即下载 身份认证后 购VIP低至7折
又说骚话 经典书籍,值得研究
yunfei181 好东西,谢谢分享~~
沁瀞洳泳 经典书籍,值得研究。
walter_sun 正好需要它, 謝謝分享!!
peakcrab 清晰英文版,目录做的不是很好
mxc880922 很好呀,非常有用
jerrycell 是原版英文的;挺清晰的
尐辣酱 不错,挺清晰的
wyh3265 很好,很不错,对初学者有很大帮助
qbj001 好东西,正是我所需要的。
  • 分享王者

关注 私信
Java核心技术(卷2):高级特性(原书第9版) 10积分/C币 立即下载

试读结束, 可继续阅读

10积分/C币 立即下载