Java FileDescriptor

FileDescriptor class serves as an handle to the underlying machine-specific structure representing an open file, an open socket, or another source or sink of bytes. The handle can be err, in or out.

The FileDescriptor class is used to create a FileInputStream or FileOutputStream to contain it.

Field

ModifierTypeFieldDescription
staticFileDescriptorerrA handle to the standard error stream.
staticFileDescriptorinA handle to the standard input stream.
staticFileDescriptoroutA handle to the standard output stream.

Constructors

ConstructorDescription
FileDescriptor()Constructs an (invalid) FileDescriptor object.

Method

Modifier and TypeMethodDescription
voidsync()It force all system buffers to synchronize with the underlying device.
booleanvalid()It tests if this file descriptor object is valid.

Java FileDescriptor Example

Output:

0123456789:
Sync() successfully executed!!

Record.txt:

0123456789:





Latest Courses