Start of Tutorial > Start of Trail |
Search
Feedback Form |
Often a program needs to bring in information from an external source or to send out information to an external destination. The information can be anywhere: in a file, on disk, somewhere on the network, in memory, or in another program. Also, the information can be of any type: objects, characters, images, or sounds. This chapter covers the Java platform classes that your programs can use to read and to write data.Overview of I/O Streams
This section describes each type of stream and shows the classes injava.io
that implement them according to the division in the class hierarchy.Using the Streams
This section has several "how-to" pages to show you how to use selected streams based on their purpose:Object Serialization
Two of the byte streams,ObjectInputStream
andObjectOutputStream
, are specialized streams that let you read and write objects. Reading and writing objects is a process known as object serialization. Object serialization has many uses, including remote method invocation (RMI). In addition to the object streams,java.io
has other classes and interfaces that define the API to help classes perform serialization for its instances.Working with Random Access Files
The character and byte streams are all sequential access streams. In contrast,RandomAccessFile
lets you randomly access the contents of a file. This section talks about how to use random access files. It also provides a special section that shows you how to write filters for objects that implement theDataInput
andDataOutput
interfaces. Filters implemented in this fashion are more flexible than regular filter streams because they can be used on random access files and on some sequential files.And the Rest ...
This section introduces the remaining classes injava.io
.Summary
A summary of the key points covered in this trail.Questions and Exercises
Test what you've learned in this trail by trying these questions and exercises.The I/O Classes in Action
Many of the examples in the next trail, Custom Networking use the I/O streams described in this lesson to read from and write toURL
s,URLConnection
s, andSocket
s.
Security consideration: Some I/O operations are subject to approval by the current security manager. The example programs contained in these lessons are standalone applications, which by default have no security manager. This code might not work in an applet depending on the in which browser or viewer it is running. See Security Restrictions for information about the security restrictions placed on applets.
Start of Tutorial > Start of Trail |
Search
Feedback Form |
Copyright 1995-2005 Sun Microsystems, Inc. All rights reserved.