Java FileOutputStream.getFD()

Syntax

FileOutputStream.getFD() has the following syntax.

public final FileDescriptor getFD()    throws IOException

Example

In the following code shows how to use FileOutputStream.getFD() method.


//  ww  w.  ja  v  a  2s  . c o  m

import java.io.FileDescriptor;
import java.io.FileOutputStream;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {

    // create new file output stream
    FileOutputStream fos = new FileOutputStream("C://test.txt");

    // get file descriptor instance
    FileDescriptor fd = fos.getFD();

    // test if the file is valid
    boolean bool = fd.valid();

    // print
    System.out.print("Is file valid? " + bool);

  }
}