Reading and Writing Files

If your file-reading needs are relatively simple, you can use the FileInputStream class, which is a simple input-stream class derived from InputStream. This class features all the methods inherited from the InputStream class. To create an object of the FileInputStream class, you call one of its constructors, of which there are three, as shown:

FileInputStream(String name)
FileInputStream(File file)
FileInputStream(FileDescriptor fdObj)

The first constructor takes a String as the argument and uses this String to create a FileInputStream object. The second constructor creates the object from a File object, and the third creates the object from a FileDescriptor object.

As you might have guessed, the ...

Get Special Edition Using Java 2 Standard Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.