December 1999
Intermediate to advanced
816 pages
20h 27m
English
To really use streams, you need to use files. So this chapter will cover files first. Java supports two kinds of files:
File—Can only be written to sequentially
RandomAccessFile—Can be read from or written to at any point in the file
To be able to use a file in Java, you create a File or RandomAccessFile object.
Warning
It is critical to remember that creating a File object such as
File myFile = new File("/export", config.dat");
does not have anything to do with whether or not this file exists. You can execute this constructor for a nonexistent file. Java does not throw an exception for a nonexistent file until you actually try to create a stream that uses the file.
The File class has three constructors ...
Read now
Unlock full access