Home > Store

Java Application Programming Interface, Volume 1, The: Core Packages

Register your product to gain access to bonus material or receive a coupon.

Java Application Programming Interface, Volume 1, The: Core Packages

Book

  • Sorry, this book is no longer in print.
Not for Sale

Description

  • Copyright 1996
  • Edition: 1st
  • Book
  • ISBN-10: 0-201-63453-8
  • ISBN-13: 978-0-201-63453-2

The popularization of the World Wide Web has catapulted the Java language into the limelight. Java is a general-purpose, object-oriented language that was designed to be robust, secure, and to run on a variety of machines and operating systems. Like HTML pages, compiled Java programs are network- and platform-independent. With Java as an extension language, Web browsers can have almost unlimited capabilities.

The Java Application Programming Interface describes the libraries that every programmer can use to write Java applications and applets. These two volumes were written by the development team that created the Java API. They are authoritative, accurate, comprehensive, and completely up to date.

Volume 1: Core Packages describes the libraries that are the foundation of the Java language. These libraries include java.lang, java.io. java.util, and java.net. These are the general-purpose libraries fundamental to every Java program.

Volume 2: Window Toolkit and Applets describes the libraries that you can use to create sophisticated and visually appealing Java applications and applets. In addition, this volume illustrates how you can create embedded programs that can be transported safely across the network. These libraries include java.awt, java.awt.image, java.awt.peer, and java.applet.

Every Java programmer who wants to create secure, efficient, portable, and robust applications should have a thorough knowledge of the Java API.



0201634538B04062001

Sample Content

Table of Contents

VOLUME I.

Preface.

A Bit of History.

About The Java Series.

Contributors to the API.

About the Java Packages.

References.

Class Hierarchy Diagrams.
Package java.lang.

Classes.

Class Boolean.

Class Character.

Class Class.

Class ClassLoader.

Class Compiler.

Class Double.

Class Float.

Class Integer.

Class Long.

Class Math.

Class Number.

Class Object.

Class Process.

Class Runtime.

Class SecurityManager.

Class String.

Class StringBuffer.

Class System.

Class Thread.

Class ThreadGroup.

Class Throwable.

Interfaces.

Interface Cloneable.

Interface Runnable.

Exceptions.

Class ArithmeticException.

Class ArrayIndexOutOfBoundsException.

Class ArrayStoreException.

Class ClassCastException.

Class ClassNotFoundException.

Class CloneNotSupportedException.

Class Exception.

Class IllegalAccessException.

Class IllegalArgumentException.

Class IllegalMonitorStateException.

Class IllegalThreadStateException.

Class IndexOutOfBoundsException.

Class InstantiationException.

Class InterruptedException.

Class NegativeArraySizeException.

Class NoSuchMethodException.

Class NullPointerException.

Class NumberFormatException.

Class RuntimeException.

Class SecurityException.

Class StringIndexOutOfBoundsException.

Errors.

Class AbstractMethodError.

Class ClassCircularityError.

Class ClassFormatError.

Class Error.

Class IllegalAccessError.

Class IncompatibleClassChangeError.

Class InstantiationError.

Class InternalError.

Class LinkageError.

Class NoClassDefFoundError.

Class NoSuchFieldError.

Class NoSuchMethodError.

Class OutOfMemoryError.

Class StackOverflowError.

Class ThreadDeath.

Class UnknownError.

Class UnsatisfiedLinkError.

Class VerifyError.

Class VirtualMachineError.

Package java.io.

Classes.

Class BufferedInputStream.

Class BufferedOutputStream.

Class ByteArrayInputStream.

Class ByteArrayOutputStream.

Class DataInputStream.

Class DataOutputStream.

Class File.

Class FileDescriptor.

Class FileInputStream.

Class FileOutputStream.

Class FilterInputStream.

Class FilterOutputStream.

Class InputStream.

Class LineNumberInputStream.

Class OutputStream.

Class PipedInputStream.

Class PipedOutputStream.

Class PrintStream.

Class PushbackInputStream.

Class RandomAccessFile.

Class SequenceInputStream.

Class StreamTokenizer.

Class StringBufferInputStream.

Interfaces.

Interface DataInput.

Interface DataOutput.

Interface FilenameFilter.

Exceptions.

Class EOFException.

Class FileNotFoundException.

Class IOException.

Class InterruptedIOException.

Class UTFDataFormatException.

Package java.util.

Classes.

Class BitSet.

Class Date.

Class Dictionary.

Class Hashtable.

Class Observable.

Class Properties.

Class Random.

Class Stack.

Class StringTokenizer.

Class Vector.

Interfaces.

Interface Enumeration.

Interface Observer.

Exceptions.

Class EmptyStackException.

Class NoSuchElementException.

Package java.net.

Classes.

Class ContentHandler.

Class DatagramPacket.

Class DatagramSocket.

Class InetAddress.

Class ServerSocket.

Class Socket.

Class SocketImpl.

Class URL.

Class URLConnection.

Class URLEncoder.

Class URLStreamHandler.

Interfaces.

Interface ContentHandlerFactory.

Interface SocketImplFactory.

Interface URLStreamHandlerFactory.

Exceptions.

Class MalformedURLException.

Class ProtocolException.

Class SocketException.

Class UnknownHostException.

Class UnknownServiceException.

Index.

VOLUME II.

Preface.

A Bit of History.

About The Java Series.

Contributors to the API.

About the Java Packages.

References.

Class Hierarchy Diagrams.
Package java.awt.

Classes.

Class BorderLayout.

Class Button.

Class Canvas.

Class CardLayout.

Class Checkbox.

Class CheckboxGroup.

Class CheckboxMenuItem.

Class Choice.

Class Color.

Class Component.

Class Container.

Class Dialog.

Class Dimension.

Class Event.

Class FileDialog.

Class FlowLayout.

Class Font.

Class FontMetrics.

Class Frame.

Class Graphics.

Class GridBagConstraints.

Class GridBagLayout.

Class GridLayout.

Class Image.

Class Insets.

Class Label.

Class List.

Class MediaTracker.

Class Menu.

Class MenuBar.

Class MenuComponent.

Class MenuItem.

Class Panel.

Class Point.

Class Polygon.

Class Rectangle.

Class Scrollbar.

Class TextArea.

Class TextComponent.

Class TextField.

Class Toolkit.

Class Window.

Interfaces.

Interface LayoutManager.

Interface MenuContainer.

Exceptions.

Class AWTException.

Errors.

Class AWTError.

Package java.awt.image.

Classes.

Class ColorModel.

Class CropImageFilter.

Class DirectColorModel.

Class FilteredImageSource.

Class ImageFilter.

Class IndexColorModel.

Class MemoryImageSource.

Class PixelGrabber.

Class RGBImageFilter.

Interfaces.

Interface ImageConsumer.

Interface ImageObserver.

Interface ImageProducer.

Package java.awt.peer.

Interfaces.

Interface ButtonPeer.

Interface CanvasPeer.

Interface CheckboxMenuItemPeer.

Interface CheckboxPeer.

Interface ChoicePeer.

Interface ComponentPeer.

Interface ContainerPeer.

Interface DialogPeer.

Interface FileDialogPeer.

Interface FramePeer.

Interface LabelPeer.

Interface ListPeer.

Interface MenuBarPeer.

Interface MenuComponentPeer.

Interface MenuItemPeer.

Interface MenuPeer.

Interface PanelPeer.

Interface ScrollbarPeer.

Interface TextAreaPeer.

Interface TextComponentPeer.

Interface TextFieldPeer.

Interface WindowPeer.

Package java.applet.

Classes.

Class Applet.

Interfaces.

Interface AppletContext.

Interface AppletStub.

Interface AudioClip.

Index. 0201634538T04062001

Preface

A Bit of History

Java is a general-purpose object-oriented programming language. Its syntax is similar to C and C++, but it omits semantic features that make C and C++ complex, confusing, and insecure. Java was initially developed to address the problems of building software for small distributed systems to embed in consumer devices. As such it was designed for heterogeneous networks, multiple host architectures, and secure delivery. To meet these requirements, compiled Java code had to survive transport across networks, operate on any client, and assure the client that it was safe to run.

The popularization of the World Wide Web helped catapult these attributes of Java into the limelight. The Internet demonstrated how interesting, media-rich content could be made accessible in simple ways. Web browsers like Mosaic enabled millions of people to roam the Net and made Web surfing part of popular culture. At last there was a medium where what you saw and heard was essentially the same whether you were using a Mac, PC, or UNIX machine, connected to a high-speed network or a modem.

With popularity comes scrutiny, however, and soon Web enthusiasts felt that the content supported by the Web's HTML document format was too limited. HTML extensions, such as forms, only highlighted those limitations while making it clear that no browser could include all the features users wanted. Extensibility was the answer. At just this time the Java programming language found itself looking for another application.

Sun's HotJava browser was developed to showcase Java's interesting properties by making it possible to embed Java programs inside Web pages. These Java programs, known as applets, are transparently downloaded into the HotJava browser along with the HTML pages in which they appear. Before being accepted by the browser, applets are carefully checked to make sure they are safe. Like HTML pages, compiled Java programs are network- and platform-independent. Applets behave the same regardless of where they come from or what kind of machine they are being loaded into.

The Web community quickly noticed that Java was something new and important. With Java as the extension language, a Web browser could have limitless capabilities. Programmers could write an applet once and it would then run on any machine, anywhere. Visitors to Java-powered Web pages could use the content found there with confidence that nothing would damage their machine.

With applets as the initial focus, Java has demonstrated a new way to make use of the Internet to distribute software. This new paradigm goes beyond browsers. We believe it is an innovation with the potential to change the course of computing.

Tim Lindholm
Senior Staff Engineer
JavaSoft
April 1996


About the Java Series

The Java Series provides definitive reference documentation for Java programmers and end users. These books are written by members of the Java Team and published under the auspices of JavaSoft, a Sun Microsystems business. The World Wide Web allows Java documentation to be made available over the Internet, either by downloading or as hypertext. Nevertheless, the world wide interest in Java led us to write these books.

To learn the latest about Java or to download the latest Java release, visit our World Wide Web site at http://java.sun.com. For updated information about The Java Series, including sample code, errata, and previews of forthcoming books, visit http://java.sun.com/books/Series.

We would like to thank the Corporate and Professional Publishing Group at Addison-Wesley for their partnership in putting together the Series. Our editor, Mike Hendrickson, and his team have done a superb job of navigating us through the world of publishing. The support of James Gosling, Ruth Hennigar, and Bill Joy of Sun Microsystems ensured that this series would have the resources it needed to be successful. A personal note of thanks to my children, Christopher and James, for putting a positive spin on the many trips to my office during the development of the Series.

Lisa Friendly
Series Editor


Contributors to the API

Designers of Classes and Interfaces
Tom Ball
Lee Boynton
Patrick Chan
David Connelly
Pavani Diwanji
Amy Fowler
James Gosling
Jim Graham
Herb Jellinek
Bill Joy
Tim Lindholm
Sami Shaio
Doug Stein
Arthur van Hoff
Chris Warth
Frank Yellin

Testers
Carla Schroer
Kevin Smith
Vijay Srinivasan
Headley Williamson

Layout and Supplemental Documentation
Lisa Friendly
James Gosling
Jonni Kanerva
Guy Steele
Annette Wagner
Kathy Walrath
Frank Yellin


About the Java Packages

These two volumes describe the Java Application Programming Interface (API), a standard set of libraries for writing Java programs. The libraries evolved over several years of writing Java code to implement a variety of systems, ranging from consumer device networks to animated user interfaces to operating systems to compilers. In 1995, the libraries were reorganized to support Internet programming, and thus the Java API was created. Many people, both from inside and outside Sun, have been involved in the design of the API.

Although the API has not reached perfection yet, we believe it is useful and hope to make it a ubiquitous layer, available to all Internet applications.

Have fun.

Arthur van Hoff


Introduction

These books are reference manuals for Java application and applet programmers. To make full use of them you should be familiar with the Java programming language and its core concepts such as object orientation, garbage collection, and multithreading.

The extent of the API and the choice of functionality have been driven by several factors. First and foremost, the API should be simple and easy to use. Parts of the API, such as the support for multithreading, might introduce functionality that is new to you, but we think you will find these new concepts simpler and easier to use than in most other programming environments.

The libraries in these books are the first generation of an API for writing Internet programs. A simple form of an Internet program is an applet-a small Java program that can be embedded in an HTML page.

The API has been designed with the Java language in mind. Important Java features such as object orientation, garbage collection, and multithreading played an important role in the API design. Instead of taking existing libraries and simply rewriting them in Java, we designed and implemented the API with full use of the Java language.

For Java 1.0, we have tried to stay away from certain complex functionality, such as video and 3D, so that library implementations can be ported easily. We can include only functionality that is not proprietary and that is easily implemented on many platforms.

We expect to add to the API, but not to subtract from it or change its behavior. The API documented in this book will remain available to all Java programs through future releases.

If you have ideas about how the API could be improved or how to implement some of the missing functionality, we would like to hear from you. Please send your ideas and implementations to java@java.sun.com.

Using These API Books

Do not get overwhelmed by the multitude of classes documented in these two books. The structure of the Java language encourages the programmer to break up libraries into many classes, each describing a small part of the functionality. The class diagrams in the following section are a good starting point for getting an impression of the relationships among classes.

As you design and implement Java programs, you should write short test programs to verify your understanding of the classes. When in doubt, try it out!

The Java web site, http://java.sun.com/, contains many excellent and sometimes interactive explanations that can help you along. Another good source of information is the newsgroup comp.lang.java.

Package Overview

This overview describes each package in the Java API, starting with the most general-purpose package (java.lang) and ending with one of the most specialized packages (java.applet). Each package groups classes and interfaces that have similar functionality. The API contains the following packages:

Volume I: Core Packages

  • java.lang: The Java Language Package
  • java.io: The Java I/O Package
  • java.util: The Java Utility Package
  • java.net: The Java Networking Package

Volume 2: Window Toolkit and Applets
  • java.awt: The Abstract Window Toolkit (AWT) Package
  • java.awt.image: The AWT Image Package
  • java.awt.peer: The AWT Peer Package
  • java.applet: The Java Applet Package

java.lang: The Java Language Package
The java.lang package provides the classes and interfaces that form the core of the Java language and the Java Virtual Machine. For example, the classes Object, String, and Thread are used by almost every program and are closely intertwined with the Java language definition. Other java.lang classes define the exceptions and errors that the Java Virtual Machine can throw.

Another set of java.lang classes provide wrappers for primitive types. For example, the Integer class provides objects to contain int values.

Still other classes, such as ClassLoader, Process, Runtime, Security-Manager, and System, provide access to system resources. For other generally useful classes, see the java.util package.

The java.lang package is imported automatically into every Java program.

java.io: The Java I/O Package
The java.io package provides a set of input and output (I/O) streams used to read and write data to files or other I/O sources. Java streams are byte oriented and the classes defined here can be chained to implement more sophisticated stream functionality.

java.util: The Java Utility Package
The java.util package contains a collection of utility classes and related interfaces. It includes classes that provide generic data structures (Dictionary, Hashtable, Stack, Vector), string manipulation (StringTokenizer), and calendar and date utilities (Date).

The java.util package also contains the Observer interface and Observable class, which allow objects to notify one another when they change.

java.net: The Java Networking Package
The java.net package contains networking classes and interfaces, including classes that represent a URL and a URL connection, classes that implement a socket connection, and a class that represents an Internet address.

java.awt: The Abstract Window Toolkit (AWT) Package
The java.awt package provides the standard graphical user interface (GUI) elements such as buttons, lists, menus, and text areas. It also includes containers (such as windows and menu bars) and higher-level components (such as dialogs for opening and saving files). The AWT contains two more packages: java.awt.image and java.awt.peer.

java.awt.image: The AWT Image Package
The java.awt.image package contains classes and interfaces for performing sophisticated image processing. These classes and interfaces can be used by applications that need to create or manipulate images and colors.

java.awt.peer: The AWT Peer Package
The java.awt.peer package contains interfaces used to connect AWT components to their window system-specific implementations (such as Motif widgets).

Unless you are creating a window system-specific implementation of the AWT, you should not need to use the interfaces in the java.awt.peer package.

java.applet: The Applet Package
The java.applet package contains classes and interfaces for creating applets.

References

IEEE Standard for Binary Floating-Point Arithmetic, ANSI/IEEE Std. 754-1985. Available from Global Engineering Documents, 15 Inverness Way East, Englewood, Colorado 80112-5704 USA, 303-792-2181 or 800-854-7179.

The Unicode Standard: Worldwide Character Encoding, Version 1.0, Volume 1 ISBN 0-201-56788-1 and Volume 2 ISBN 0-201-60845-6. Additional information about Unicode 1.1 may be found at ftp://unicode.org.



0201634538P04062001

Updates

Errata

Click below for Errata related to this title:
Errata

Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020