Code example for FileDescriptor

0
 
    /** 
     * @tests java.io.FileDescriptor#FileDescriptor() 
     */ 
    public void test_Constructor() { 
        FileDescriptor fd = new FileDescriptor();
        assertTrue("Failed to create FileDescriptor",
                fd instanceof FileDescriptor);
    } 
 
    /** 
     * @tests java.io.FileDescriptor#sync() 
     */ 
    public void test_sync() throws IOException { 
        f = new File(System.getProperty("user.dir"), "fd" + platformId + ".tst");
        f.delete();
        fos = new FileOutputStream(f.getPath());
        fos.write("Test String".getBytes());
        fis = new FileInputStream(f.getPath());
        FileDescriptor fd = fos.getFD();
        fd.sync();