public final class

FileDescriptor

extends Object
java.lang.Object
   ↳ java.io.FileDescriptor

Class Overview

The lowest-level representation of a file, device, or socket. If is often used for wrapping an operating system "handle". Some I/O classes can be queried for the FileDescriptor they are operating on, and this descriptor can subsequently be used during the instantiation of another I/O class, so that the new object will reuse it.

The FileDescriptor class also contains static fields representing the system's standard input, output and error streams. These can be used directly if desired, but it is recommended to go through System.in, System.out, and System.err streams respectively.

Applications should not create new FileDescriptors.

Summary

Constants
FileDescriptor err FileDescriptor representing standard error.
FileDescriptor in The FileDescriptor representing standard input.
FileDescriptor out FileDescriptor representing standard out.
Public Constructors
FileDescriptor()
Constructs a new FileDescriptor containing an invalid handle.
Public Methods
void sync()
Ensures that data which is buffered within the underlying implementation is written out to the appropriate device before returning.
String toString()
Returns a string containing a concise, human-readable description of this object.
boolean valid()
Indicates whether this FileDescriptor is valid.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final FileDescriptor err

Since: API Level 1

FileDescriptor representing standard error.

public static final FileDescriptor in

Since: API Level 1

The FileDescriptor representing standard input.

public static final FileDescriptor out

Since: API Level 1

FileDescriptor representing standard out.

Public Constructors

public FileDescriptor ()

Since: API Level 1

Constructs a new FileDescriptor containing an invalid handle. The contained handle is usually modified by native code at a later point.

Public Methods

public void sync ()

Since: API Level 1

Ensures that data which is buffered within the underlying implementation is written out to the appropriate device before returning.

Throws
SyncFailedException when the operation fails.

public String toString ()

Since: API Level 1

Returns a string containing a concise, human-readable description of this object. Subclasses are encouraged to override this method and provide an implementation that takes into account the object's type and data. The default implementation is equivalent to the following expression:

   getClass().getName() + '@' + Integer.toHexString(hashCode())

See Writing a useful toString method if you intend implementing your own toString method.

Returns
  • a printable representation of this object.

public boolean valid ()

Since: API Level 1

Indicates whether this FileDescriptor is valid.

Returns
  • true if this FileDescriptor is valid, false otherwise.