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.
In Chapter 1, you will learn all about the Java 8 stream library that brings a modern flavor to
processing data, by specifying what you want without describing in detail how the result
should be obtained. This allows the stream library to focus on an optimal evaluation strategy,
which is particularly advantageous for optimizing concurrent computations.
The topic of Chapter 2 is input and output handling (I/O). In Java, all input and output is
handled through input/output streams. These streams (not to be confused with those in Chapter
1) 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 working
with files and paths.
Chapter 3 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 API, which makes “finding needles in
XML haystacks” much easier.
Chapter 4 covers the networking API. 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 5 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 big 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).
Java had two prior attempts at libraries for handling date and time. The third one is the charm
in Java 8. In Chapter 6, you will learn how to deal with the complexities of calendars and
time zones, using the new date and time library.
Chapter 7 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 cross
not only platforms but country boundaries as well. For example, we show you how to write a
retirement calculator that uses either English, German, or Chinese languages.
Chapter 8 discusses three techniques for processing code. The scripting and compiler APIs
allow your program to call code in scripting languages such as JavaScript 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 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-purpose applications. Then, we take up the security API that allows for such important
features as message and code signing, authorization and authentication, and encryption. We
conclude with examples that use the AES and RSA encryption algorithms.
Chapter 10 contains all the Swing material that didn’t make it into Volume I, 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 11 covers the Java 2D API, 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 12 takes up native methods, which let you call methods written for a specific
machine such as the Microsoft Windows API. Obviously, this feature is controversial: Use
native methods, and the cross-platform nature of Java vanishes. Nonetheless, 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 API 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 APIs of Java SE 8 are covered in detail.

0 comments:

 
Top