As I’ve said several times so far, the existence of a
java.io.File object doesn’t imply the
existence of the file it represents. A
java.io.FileDescriptor object does, however, refer
to an actual file:
public final class FileDescriptor extends Object
object is an abstraction of an underlying
machine-specific structure that represents an open file. While file
descriptors are very important for the underlying OS and filesystem,
their only real use in Java is to guarantee that data that’s
been written to a stream is in fact committed to disk; that is, to
synchronize between the program and the hardware.
In addition to open files, file descriptors can also represent open
sockets, though this use won’t be emphasized in this book.
There are also three file descriptors for the console:
System.err. These are available as the three
public static final FileDescriptor in public static final FileDescriptor out public static final FileDescriptor err
Because file descriptors are very closely tied to the native
operating system, you never construct your own file descriptors.
Various methods in other classes that refer to open files or sockets
may return them. Both the
FileOutputStream classes and the
RandomAccessFile class have a
getFD() method that returns the file descriptor
associated with the open stream or file:
public final FileDescriptor ...