FileDocCategorySizeDatePackage
FileDescriptor.javaAPI DocAndroid 1.5 API3739Wed May 06 22:41:04 BST 2009java.io

FileDescriptor

public final class FileDescriptor extends Object
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.

see
FileInputStream#getFD()
see
FileOutputStream#getFD()
see
RandomAccessFile#getFD()
since
Android 1.0

Fields Summary
public static final FileDescriptor
in
The FileDescriptor representing standard input.
public static final FileDescriptor
out
FileDescriptor representing standard out.
public static final FileDescriptor
err
FileDescriptor representing standard error.
int
descriptor
Represents a link to any underlying OS resources for this FileDescriptor. A value of -1 indicates that this FileDescriptor is invalid.
boolean
readOnly
Constructors Summary
public FileDescriptor()
Constructs a new FileDescriptor containing an invalid handle. The contained handle is usually modified by native code at a later point.

since
Android 1.0

 

        

     
        in.descriptor = 0;
        out.descriptor = 1;
        err.descriptor = 2;

        oneTimeInitialization();
    
        super();
    
Methods Summary
private static native voidoneTimeInitialization()

public voidsync()
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.
since
Android 1.0

        // if the descriptor is a read-only one, do nothing
        if (!readOnly) {
            syncImpl();
        }
    
private native voidsyncImpl()

public native booleanvalid()
Indicates whether this FileDescriptor is valid.

return
{@code true} if this FileDescriptor is valid, {@code false} otherwise.
since
Android 1.0