java.io

Class FileDescriptor


public final class FileDescriptor
extends Object

Instances of the file descriptor class serve as an opaque handle to the underlying machine-specific structure representing an open file, an open socket, or another source or sink of bytes. The main practical use for a file descriptor is to create a FileInputStream or FileOutputStream to contain it.

Applications should not create their own file descriptors.

Since:
JDK1.0
See Also:
FileInputStream, FileOutputStream

Field Summary

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.

Constructor Summary

FileDescriptor()
Constructs an (invalid) FileDescriptor object.

Method Summary

void
sync()
Force all system buffers to synchronize with the underlying device.
boolean
valid()
Tests if this file descriptor object is valid.

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

err

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 System.err.
See Also:
System.err
Usages and Demos :

View More Examples of err
   1:     this(new PrintStream
   2:      (new FileOutputStream(FileDescriptor.err), true), 
   3:      maxdepth, 
   4:      maxdepth > 0 ? 1000 : 10, printStaticFields);
   5:   }

View Full Code Here
   1:     }
   2:     FileInputStream  fdIn  = new FileInputStream(FileDescriptor.in);
   3:         ...
   4:     FileOutputStream fdOut = new FileOutputStream(FileDescriptor.out);
   5:         ...
   6:     FileOutputStream fdErr = new FileOutputStream(FileDescriptor.err);
   7:     System.setIn(new BufferedInputStream(fdIn));
   8:         ...
   9:           try {
  10:             System.err.flush();

View Full Code Here

in

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 System.in.
See Also:
System.in
Usages and Demos :

View More Examples of in
   1: import java.io.File;
   2: import java.io.FileDescriptor;
   3: import java.io.FileInputStream;
   4:         ...
   5:   static public OpenEntity openStandardInput() throws IOException {
   6:     return new OpenEntity(new FileInputStream(FileDescriptor.in),
   7:               "<standard input>",
   8:               userDirURL(),
   9:               null);

View Full Code Here
   1: import java.io.File;
   2: import java.io.FileDescriptor;
   3: import java.io.FileInputStream;
   4:         ...
   5:             if(stream == null) {
   6:                 stream = new FileInputStream(FileDescriptor.in);
   7:             }
   8: 
   9:             begin(stream, base, mode);

View Full Code Here
   1:     }
   2:     FileInputStream  fdIn  = new FileInputStream(FileDescriptor.in);
   3:         ...
   4:     FileOutputStream fdOut = new FileOutputStream(FileDescriptor.out);
   5:         ...
   6:     FileOutputStream fdErr = new FileOutputStream(FileDescriptor.err);
   7:     System.setIn(new BufferedInputStream(fdIn));

View Full Code Here
   1: 
   2: import java.io.FileDescriptor;
   3: import java.io.FileInputStream;
   4:         ...
   5:             if (stream == null) {
   6:                 stream = new FileInputStream(FileDescriptor.in);
   7:             }
   8:             CmsShell shell = new CmsShell(
   9:                 webInfPath,

View Full Code Here

out

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 System.out.
See Also:
System.out
Usages and Demos :

View More Examples of out
   1:                          new BufferedWriter(
   2:                          new FileWriter(FileDescriptor.out)));
   3: 
   4:     for(int i=0; i < primes.length; i++)
   5:       output.print((i%5==0 ? "\n" : "  ") + primes[i]);

View Full Code Here
   1:                        new BufferedWriter(
   2:                        new FileWriter(FileDescriptor.out)), 12);
   3: 
   4:     for(int i=0; i < primes.length; i++)
   5:     {

View Full Code Here
   1:     Parser parser = new ParserImpl();
   2:     parser.setApplication(new Normalize(new UTF8XMLWriter(new FileOutputStream(FileDescriptor.out))));
   3:     try {
   4:       parser.parseDocument(args.length == 0
   5:                ? EntityManagerImpl.openStandardInput()

View Full Code Here
   1:                          new BufferedWriter(
   2:                          new FileWriter(FileDescriptor.out)));
   3: 
   4:         ...
   5:     {
   6:       System.out.println("Error reading input file" + e );
   7:       return;
   8:     }
   9:   }

View Full Code Here
   1: 
   2:       System.out.print("Enter the number of primes required: ");
   3: 
   4:         ...
   5:                          new BufferedWriter(
   6:                          new FileWriter(FileDescriptor.out)), true, 12);
   7: 
   8:     {

View Full Code Here

Constructor Details

FileDescriptor

public FileDescriptor()
Constructs an (invalid) FileDescriptor object.
Usages and Demos :

View More Examples of FileDescriptor()
   1: 
   2:     stdin_fd = new FileDescriptor();
   3:         ...
   4:     stdout_fd = new FileDescriptor();
   5:         ...
   6:     stderr_fd = new FileDescriptor();
   7:     sync_fd = new FileDescriptor();

View Full Code Here
   1: 
   2:         mStdIn = new FileDescriptor();
   3:         ...
   4:         mStdOut = new FileDescriptor();
   5:         ...
   6:         mStdErr = new FileDescriptor();
   7:         String path = (workingDir == null?null:workingDir.getAbsolutePath());

View Full Code Here
   1:     {
   2:     FileDescriptor fdInObj = new FileDescriptor();
   3: 
   4:         ...
   5:     FileDescriptor fdOutObj = new FileDescriptor();
   6: 
   7:     mtaskIn = new BufferedReader(new FileReader(fdInObj));

View Full Code Here
   1:     socket_fd = -1;
   2:     fd = new FileDescriptor();
   3:   }
   4: 

View Full Code Here
   1:     KaffeSerialPort(String name) {
   2:     fd = new FileDescriptor();
   3:     open(name);
   4:     this.name = name;
   5:     }

View Full Code Here

Method Details

sync

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 FileDesecriptor 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.
Throws:
SyncFailedException - Thrown when the buffers cannot be flushed, or because the system cannot guarantee that all the buffers have been synchronized with physical media.
Since:
JDK1.1
Usages and Demos :

View More Examples of sync()
   1: import java.io.File;
   2: import java.io.FileDescriptor;
   3: import java.io.FileInputStream;
   4:         ...
   5:     private File file;
   6:     private FileDescriptor fd;
   7: 
   8:         ...
   9:                 try {
  10:                     fd.sync();
  11:                 } catch (SyncFailedException e) {

View Full Code Here
   1:     private RandomAccessFile log = null;
   2:     private FileDescriptor logFD;
   3:     private long snapshotBytes = 0;
   4:         ...
   5:             try {
   6:             logFD.sync();
   7:             } catch (SyncFailedException sfe) {
   8:             throw new LogException("sync log failed", sfe);
   9:             }

View Full Code Here
   1:             
   2:             fileDesc.sync();
   3:             }
   4:         }
   5:         catch (SyncFailedException e)

View Full Code Here

valid

public boolean valid()
Tests if this file descriptor object is valid.
Returns:
true if the file descriptor object represents a valid, open file, socket, or other active I/O connection; false otherwise.