FileInputStream
or FileOutputStream
to contain it.
Applications should not create their own file descriptors.
Modifier and Type | Field and Description |
---|---|
private boolean | append
true, if file is opened for appending. |
private PhantomCleanable | cleanup
Cleanup in case FileDescriptor is not explicitly closed. |
private boolean | |
public static final FileDescriptor | err
A handle to the standard error stream. |
private int | |
private long | |
public static final FileDescriptor | in
A handle to the standard input stream. |
private List | |
public static final FileDescriptor | out
A handle to the standard output stream. |
private Closeable |
Access | Constructor and Description |
---|---|
public | |
private |
Modifier and Type | Method and Description |
---|---|
pack-priv synchronized void | |
pack-priv synchronized void | |
private native void | |
pack-priv synchronized void | |
private static native boolean | |
private static native long | |
private static native void | |
pack-priv synchronized void | registerCleanup(PhantomCleanable<FileDescriptor>
a PhantomCleanable to register cleanable)Register a cleanup for the current handle. |
pack-priv synchronized void | |
pack-priv void | |
public void | |
private native void | |
pack-priv synchronized void | |
public boolean | Returns: true if the file descriptor object represents a
valid, open file, socket, or other active I/O connection;
false otherwise.Tests if this file descriptor object is valid. |
append | back to summary |
---|---|
private boolean append true, if file is opened for appending. |
cleanup | back to summary |
---|---|
private PhantomCleanable<FileDescriptor> cleanup Cleanup in case FileDescriptor is not explicitly closed. |
closed | back to summary |
---|---|
private boolean closed |
err | back to summary |
---|---|
public static final FileDescriptor err A handle to the standard error stream. Usually, this file
descriptor is not used directly, but rather via the output stream
known as
|
fd | back to summary |
---|---|
private int fd |
handle | back to summary |
---|---|
private long handle |
in | back to summary |
---|---|
public static final FileDescriptor in A handle to the standard input stream. Usually, this file
descriptor is not used directly, but rather via the input stream
known as
|
otherParents | back to summary |
---|---|
private List<Closeable> otherParents |
out | back to summary |
---|---|
public static final FileDescriptor out A handle to the standard output stream. Usually, this file
descriptor is not used directly, but rather via the output stream
known as
|
parent | back to summary |
---|---|
private Closeable parent |
FileDescriptor | back to summary |
---|---|
public FileDescriptor() Constructs an (invalid) FileDescriptor object. The fd or handle is set later. |
FileDescriptor | back to summary |
---|---|
private FileDescriptor(int fd) Used for standard input, output, and error only. For Windows the corresponding handle is initialized. For Unix the append mode is cached.
|
attach | back to summary |
---|---|
pack-priv synchronized void attach(Closeable c) Attach a Closeable to this FD for tracking. parent reference is added to otherParents when needed to make closeAll simpler. |
close | back to summary |
---|---|
pack-priv synchronized void close() throws IOException Close the raw file descriptor or handle, if it has not already been closed. The native code sets the fd and handle to -1. Clear the cleaner so the close does not happen twice. Package private to allow it to be used in java.io.
|
close0 | back to summary |
---|---|
private native void close0() throws IOException |
closeAll | back to summary |
---|---|
pack-priv synchronized void closeAll(Closeable releaser) throws IOException Cycle through all Closeables sharing this FD and call close() on each one. The caller closeable gets to call close0().
|
getAppend | back to summary |
---|---|
private static native boolean getAppend(int fd) Returns true, if the file was opened for appending. |
getHandle | back to summary |
---|---|
private static native long getHandle(int d) |
initIDs | back to summary |
---|---|
private static native void initIDs() |
registerCleanup | back to summary |
---|---|
pack-priv synchronized void registerCleanup(PhantomCleanable<FileDescriptor> cleanable) Register a cleanup for the current handle. Used directly in java.io and indirectly via fdAccess. The cleanup should be registered after the handle is set in the FileDescriptor.
|
set | back to summary |
---|---|
pack-priv synchronized void set(int fd) Set the fd.
Used on Unix and for sockets on Windows and Unix.
If setting to -1, clear the cleaner.
The
|
setHandle | back to summary |
---|---|
pack-priv void setHandle(long handle) Set the handle.
Used on Windows for regular files.
If setting to -1, clear the cleaner.
The
|
sync | back to summary |
---|---|
public void sync() throws SyncFailedException Force all system buffers to synchronize with the underlying device. This method returns after all modified data and attributes of this FileDescriptor have been written to the relevant device(s). In particular, if this FileDescriptor refers to a physical storage medium, such as a file in a file system, sync will not return until all in-memory modified copies of buffers associated with this FileDescriptor have been written to the physical medium. sync is meant to be used by code that requires physical storage (such as a file) to be in a known state For example, a class that provided a simple transaction facility might use sync to ensure that all changes to a file caused by a given transaction were recorded on a storage medium. sync only affects buffers downstream of this FileDescriptor. If any in-memory buffering is being done by the application (for example, by a BufferedOutputStream object), those buffers must be flushed into the FileDescriptor (for example, by invoking OutputStream.flush) before that data will be affected by sync.
|
sync0 | back to summary |
---|---|
private native void sync0() throws SyncFailedException |
unregisterCleanup | back to summary |
---|---|
pack-priv synchronized void unregisterCleanup() Unregister a cleanup for the current raw fd or handle.
Used directly in java.io and indirectly via fdAccess.
Normally |
valid | back to summary |
---|---|
public boolean valid() Tests if this file descriptor object is valid.
|