Javatpoint Logo
Javatpoint Logo

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

Modifier Type Field Description
static FileDescriptor err A handle to the standard error stream.
static FileDescriptor in A handle to the standard input stream.
static FileDescriptor out A handle to the standard output stream.

Constructors

Constructor Description
FileDescriptor() Constructs an (invalid) FileDescriptor object.

Method

Modifier and Type Method Description
void sync() It force all system buffers to synchronize with the underlying device.
boolean valid() It tests if this file descriptor object is valid.

Java FileDescriptor Example

Output:

0123456789:
Sync() successfully executed!!

Record.txt:

0123456789:





Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA