Core Java, Volume 1: Fundamentals [8th ed] 9780132354769, 6176713447, 9780132354790, 0132354799, 0132354764

This revised edition of the classic "Core Java(TM), Volume I-Fundamentals," is the definitive guide to Java fo

915 115 16MB

English Pages 836 [1057] Year 2007;2008

Report DMCA / Copyright

DOWNLOAD FILE

Core Java, Volume 1: Fundamentals [8th ed]
 9780132354769, 6176713447, 9780132354790, 0132354799, 0132354764

Table of contents :
Cover......Page 1
Contents......Page 6
Preface......Page 16
Acknowledgments......Page 20
1 STREAMS AND FILES......Page 22
Reading and Writing Bytes......Page 23
The Complete Stream Zoo......Page 25
Combining Stream Filters......Page 29
Text Input and Output......Page 32
How to Write Text Output......Page 33
Saving Objects in Text Format......Page 35
Character Sets......Page 40
Reading and Writing Binary Data......Page 44
Random-Access Files......Page 47
ZIP Archives......Page 53
Object Streams and Serialization......Page 60
Understanding the Object Serialization File Format......Page 67
Modifying the Default Serialization Mechanism......Page 72
Serializing Singletons and Typesafe Enumerations......Page 74
Versioning......Page 75
Using Serialization for Cloning......Page 77
File Management......Page 80
Memory-Mapped Files......Page 86
The Buffer Data Structure......Page 93
File Locking......Page 95
Regular Expressions......Page 96
2 XML......Page 108
Introducing XML......Page 109
The Structure of an XML Document......Page 111
Parsing an XML Document......Page 114
Validating XML Documents......Page 126
Document Type Definitions......Page 127
XML Schema......Page 133
A Practical Example......Page 136
Locating Information with XPath......Page 150
Using Namespaces......Page 157
Using the SAX Parser......Page 159
Using the StAX Parser......Page 164
Generating XML Documents......Page 167
Writing an XML Document with StAX......Page 171
XSL Transformations......Page 178
3 NETWORKING......Page 190
Connecting to a Server......Page 191
Socket Timeouts......Page 195
Internet Addresses......Page 196
Implementing Servers......Page 198
Serving Multiple Clients......Page 201
Interruptible Sockets......Page 205
Sending E-Mail......Page 212
URLs and URIs......Page 217
Using a URLConnection to Retrieve Information......Page 219
Posting Form Data......Page 228
4 DATABASE PROGRAMMING......Page 238
The Design of JDBC......Page 239
JDBC Driver Types......Page 240
Typical Uses of JDBC......Page 241
The Structured Query Language......Page 243
Database URLs......Page 248
Starting the Database......Page 249
Connecting to the Database......Page 250
Executing SQL Statements......Page 253
Managing Connections, Statements, and Result Sets......Page 256
Analyzing SQL Exceptions......Page 257
Populating a Database......Page 259
Prepared Statements......Page 263
Reading and Writing LOBs......Page 271
SQL Escapes......Page 273
Multiple Results......Page 274
Scrollable Result Sets......Page 275
Updatable Result Sets......Page 277
Row Sets......Page 281
Cached Row Sets......Page 282
Metadata......Page 284
Transactions......Page 294
Batch Updates......Page 295
Advanced SQL Types......Page 297
Connection Management in Web and Enterprise Applications......Page 299
Introduction to LDAP......Page 300
Configuring an LDAP Server......Page 301
Accessing LDAP Directory Information......Page 305
5 INTERNATIONALIZATION......Page 318
Locales......Page 319
Number Formats......Page 324
Currencies......Page 330
Date and Time......Page 331
Collation Strength......Page 339
Decomposition......Page 340
Message Formatting......Page 345
Choice Formats......Page 347
Character Encoding of Source Files......Page 349
Resource Bundles......Page 350
Locating Resource Bundles......Page 351
Bundle Classes......Page 352
A Complete Example......Page 354
6 ADVANCED SWING......Page 372
The JList Component......Page 373
List Models......Page 379
Inserting and Removing Values......Page 384
Rendering Values......Page 386
A Simple Table......Page 391
Table Models......Page 395
Working with Rows and Columns......Page 399
Cell Rendering and Editing......Page 413
Trees......Page 426
Simple Trees......Page 427
Node Enumeration......Page 443
Rendering Nodes......Page 445
Listening to Tree Events......Page 448
Custom Tree Models......Page 455
Text Components......Page 463
Change Tracking in Text Components......Page 464
Formatted Input Fields......Page 468
The JSpinner Component......Page 484
Displaying HTML with the JEditorPane......Page 493
Progress Bars......Page 500
Progress Monitors......Page 504
Monitoring the Progress of Input Streams......Page 508
Split Panes......Page 513
Tabbed Panes......Page 517
Desktop Panes and Internal Frames......Page 523
Cascading and Tiling......Page 526
Vetoing Property Settings......Page 530
7 ADVANCED AWT......Page 542
The Rendering Pipeline......Page 543
Shapes......Page 545
Using the Shape Classes......Page 548
Areas......Page 561
Strokes......Page 563
Paint......Page 571
Coordinate Transformations......Page 573
Clipping......Page 578
Transparency and Composition......Page 580
Rendering Hints......Page 589
Obtaining Readers and Writers for Image File Types......Page 596
Reading and Writing Files with Multiple Images......Page 597
Constructing Raster Images......Page 606
Filtering Images......Page 613
Printing......Page 622
Graphics Printing......Page 623
Multiple-Page Printing......Page 632
Print Preview......Page 634
Print Services......Page 644
Printing Attributes......Page 648
The Clipboard......Page 656
Transferring Text......Page 657
The Transferable Interface and Data Flavors......Page 661
Building an Image Transferable......Page 663
Transferring Java Objects via the System Clipboard......Page 668
Drag and Drop......Page 673
Data Transfer Support in Swing......Page 675
Drag Sources......Page 679
Drop Targets......Page 681
Splash Screens......Page 689
Launching Desktop Applications......Page 694
The System Tray......Page 700
8 JAVABEANS COMPONENTS......Page 706
Why Beans?......Page 707
The Bean-Writing Process......Page 709
Using Beans to Build an Application......Page 711
Packaging Beans in JAR Files......Page 712
Composing Beans in a Builder Environment......Page 713
Naming Patterns for Bean Properties and Events......Page 719
Indexed Properties......Page 722
Bound Properties......Page 723
Constrained Properties......Page 724
BeanInfo Classes......Page 731
Property Editors......Page 734
Writing Property Editors......Page 737
Customizers......Page 744
Writing a Customizer Class......Page 746
JavaBeans Persistence......Page 753
Using JavaBeans Persistence for Arbitrary Data......Page 757
A Complete Example for JavaBeans Persistence......Page 763
9 SECURITY......Page 776
Class Loaders......Page 777
The Class Loader Hierarchy......Page 778
Using Class Loaders as Namespaces......Page 780
Writing Your Own Class Loader......Page 782
Bytecode Verification......Page 788
Security Managers and Permissions......Page 792
Java Platform Security......Page 793
Security Policy Files......Page 797
Implementation of a Permission Class......Page 804
User Authentication......Page 811
JAAS Login Modules......Page 816
Message Digests......Page 826
Message Signing......Page 833
Verifying a Signature......Page 835
The Authentication Problem......Page 839
Certificate Signing......Page 841
Certificate Requests......Page 842
JAR File Signing......Page 843
Software Developer Certificates......Page 848
Symmetric Ciphers......Page 849
Key Generation......Page 851
Cipher Streams......Page 855
Public Key Ciphers......Page 856
10 DISTRIBUTED OBJECTS......Page 862
The Roles of Client and Server......Page 863
Stubs and Parameter Marshalling......Page 866
Interfaces and Implementations......Page 867
The RMI Registry......Page 869
Deploying the Program......Page 873
Logging RMI Activity......Page 876
Parameters and Return Values in Remote Methods......Page 877
Transferring Nonremote Objects......Page 878
Dynamic Class Loading......Page 881
Remote References with Multiple Interfaces......Page 885
Remote Object Activation......Page 886
Using JAX-WS......Page 892
A Web Service Client......Page 895
The Amazon E-Commerce Service......Page 898
11 SCRIPTING, COMPILING, AND ANNOTATION PROCESSING......Page 904
Getting a Scripting Engine......Page 905
Script Evaluation and Bindings......Page 906
Redirecting Input and Output......Page 908
Calling Scripting Functions and Methods......Page 909
Compiling a Script......Page 910
An Example: Scripting GUI Events......Page 911
Using Compilation Tasks......Page 916
An Example: Dynamic Java Code Generation......Page 921
Using Annotations......Page 926
An Example: Annotating Event Handlers......Page 927
Annotation Syntax......Page 932
Standard Annotations......Page 936
Annotations for Compilation......Page 937
Meta-Annotations......Page 938
Source-Level Annotation Processing......Page 940
Bytecode Engineering......Page 947
Modifying Bytecodes at Load Time......Page 953
12 NATIVE METHODS......Page 956
Calling a C Function from a Java Program......Page 957
Using printf for Formatting Numbers......Page 963
String Parameters......Page 965
Accessing Instance Fields......Page 971
Accessing Static Fields......Page 974
Encoding Signatures......Page 975
Instance Methods......Page 977
Static Methods......Page 978
Alternative Method Invocations......Page 979
Accessing Array Elements......Page 983
Handling Errors......Page 987
Using the Invocation API......Page 991
Overview of the Windows Registry......Page 996
Implementation of Registry Access Functions as Native Methods......Page 998
A......Page 1012
B......Page 1014
C......Page 1016
D......Page 1020
E......Page 1022
F......Page 1024
G......Page 1025
H......Page 1027
I......Page 1028
J......Page 1030
L......Page 1032
M......Page 1033
N......Page 1035
O......Page 1036
P......Page 1037
R......Page 1040
S......Page 1043
T......Page 1048
U......Page 1050
W......Page 1051
X......Page 1052
Z......Page 1053

Polecaj historie