Package java.io

Examples of java.io.FileDescriptor


  public void test (TestHarness harness)
  {
   try {
      FileOutputStream fos = new FileOutputStream("tmpfile");
      try {
        FileDescriptor fd = fos.getFD();
        harness.check(fd.valid(), "valid()");
      try {
      fd.sync();
      harness.check(true, "sync()");
    }
    catch (SyncFailedException e) {
      harness.debug(e);
      harness.fail("SyncFailedException thrown");
View Full Code Here


     * @tests java.io.FileOutputStream#write(byte[], int, int)
     */
    public void test_write$BII3() throws IOException {
        // Regression for HARMONY-834
        // no exception expected
        new FileOutputStream(new FileDescriptor()).write(new byte[1], 0, 0);
    }
View Full Code Here

  /**
   * @tests java.io.FileDescriptor#FileDescriptor()
   */
  public void test_Constructor() {
    // Test for method java.io.FileDescriptor()
    FileDescriptor fd = new FileDescriptor();
    assertTrue("Failed to create FileDescriptor",
        fd instanceof FileDescriptor);
  }
View Full Code Here

        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();
        int length = "Test String".length();
        assertEquals("Bytes were not written after sync", length, fis
                .available());
       
        // Regression test for Harmony-1494
        fd = fis.getFD();
        fd.sync();
        assertEquals("Bytes were not written after sync", length, fis
                .available());
       
        RandomAccessFile raf = new RandomAccessFile(f, "r");
        fd = raf.getFD();
        fd.sync();
        raf.close();
  }
View Full Code Here

    try {
      f = new File(System.getProperty("user.dir"), "fd.tst");
      f.delete();
      os = new BufferedOutputStream(fos = new FileOutputStream(f
          .getPath()), 4096);
      FileDescriptor fd = fos.getFD();
      assertTrue("Valid fd returned false", fd.valid());
      os.close();
      assertTrue("Invalid fd returned true", !fd.valid());
    } catch (Exception e) {
      fail("Exception during test : " + e.getMessage());
    }

  }
View Full Code Here

     * @tests java.io.FileOutputStream#write(byte[], int, int)
     */
    public void test_write$BII3() throws Exception {
        // Regression for HARMONY-834
        //no exception expected
        new FileOutputStream(new FileDescriptor()).write(new byte[1], 0, 0);
    }
View Full Code Here

     * Constructor
     */
    public ServerSocketChannelImpl(SelectorProvider sp) throws IOException {
        super(sp);
        status = SERVER_STATUS_OPEN;
        fd = new FileDescriptor();
        Platform.getNetworkSystem().createServerStreamSocket(fd,
                NetUtil.preferIPv4Stack());
        impl = SocketImplProvider.getServerSocketImpl(fd);
        socket = new ServerSocketAdapter(impl, this);
    }
View Full Code Here

    // for native call
    @SuppressWarnings("unused")
    private ServerSocketChannelImpl() throws IOException {
        super(SelectorProvider.provider());
        status = SERVER_STATUS_OPEN;
        fd = new FileDescriptor();
        impl = SocketImplProvider.getServerSocketImpl(fd);       
        socket = new ServerSocketAdapter(impl, this);
        isBound = false;
    }
View Full Code Here

    // Test for method java.io.SyncFailedException(java.lang.String)
    File f = null;
    try {
      f = new File(System.getProperty("user.dir"), "synfail.tst");
      FileOutputStream fos = new FileOutputStream(f.getPath());
      FileDescriptor fd = fos.getFD();
      fos.close();
      fd.sync();
    } catch (SyncFailedException e) {
      f.delete();
      return;
    } catch (Exception e) {
      fail("Exception during test : " + e.getMessage());
View Full Code Here

* @author Bob McWhirter
*/
public class UnsafeFs {

    public static FileDescriptor createFileDescriptor(int fd) throws IllegalAccessException, NoSuchFieldException {
        FileDescriptor fileDesc = new FileDescriptor();
        Field f = fileDesc.getClass().getDeclaredField("fd");
        f.setAccessible(true);
        f.setInt(fileDesc, fd );
        return fileDesc;
    }
View Full Code Here

TOP

Related Classes of java.io.FileDescriptor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.