Package java.io

Examples of java.io.FileDescriptor.valid()


                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());
  }

  /**
   * Sets up the fixture, for example, open a network connection. This method
   * is called before a test is executed.
View Full Code Here


    LOG.info("Test creating a file with O_CREAT");
    FileDescriptor fd = NativeIO.POSIX.open(
      new File(TEST_DIR, "testWorkingOpen").getAbsolutePath(),
      NativeIO.POSIX.O_WRONLY | NativeIO.POSIX.O_CREAT, 0700);
    assertNotNull(true);
    assertTrue(fd.valid());
    FileOutputStream fos = new FileOutputStream(fd);
    fos.write("foo".getBytes());
    fos.close();

    assertFalse(fd.valid());
View Full Code Here

    assertTrue(fd.valid());
    FileOutputStream fos = new FileOutputStream(fd);
    fos.write("foo".getBytes());
    fos.close();

    assertFalse(fd.valid());

    LOG.info("Test exclusive create");
    try {
      fd = NativeIO.POSIX.open(
        new File(TEST_DIR, "testWorkingOpen").getAbsolutePath(),
View Full Code Here

    for (int i = 0; i < 10000; i++) {
      FileDescriptor fd = NativeIO.POSIX.open(
        new File(TEST_DIR, "testNoFdLeak").getAbsolutePath(),
        NativeIO.POSIX.O_WRONLY | NativeIO.POSIX.O_CREAT, 0700);
      assertNotNull(true);
      assertTrue(fd.valid());
      FileOutputStream fos = new FileOutputStream(fd);
      fos.write("foo".getBytes());
      fos.close();
    }
  }
View Full Code Here

     * <code>RandomAccessFile</code>.
     */
    public void flush() throws IOException {
  // Fix: 4636212.  When this FIleDescriptor is not valid, do nothing.
  FileDescriptor fd = file.getFD();
        if(fd.valid())
      fd.sync();
    }

    public void close() throws IOException {
        file.close();
View Full Code Here

    LOG.info("Test creating a file with O_CREAT");
    FileDescriptor fd = NativeIO.POSIX.open(
      new File(TEST_DIR, "testWorkingOpen").getAbsolutePath(),
      NativeIO.POSIX.O_WRONLY | NativeIO.POSIX.O_CREAT, 0700);
    assertNotNull(true);
    assertTrue(fd.valid());
    FileOutputStream fos = new FileOutputStream(fd);
    fos.write("foo".getBytes());
    fos.close();

    assertFalse(fd.valid());
View Full Code Here

    assertTrue(fd.valid());
    FileOutputStream fos = new FileOutputStream(fd);
    fos.write("foo".getBytes());
    fos.close();

    assertFalse(fd.valid());

    LOG.info("Test exclusive create");
    try {
      fd = NativeIO.POSIX.open(
        new File(TEST_DIR, "testWorkingOpen").getAbsolutePath(),
View Full Code Here

    for (int i = 0; i < 10000; i++) {
      FileDescriptor fd = NativeIO.POSIX.open(
        new File(TEST_DIR, "testNoFdLeak").getAbsolutePath(),
        NativeIO.POSIX.O_WRONLY | NativeIO.POSIX.O_CREAT, 0700);
      assertNotNull(true);
      assertTrue(fd.valid());
      FileOutputStream fos = new FileOutputStream(fd);
      fos.write("foo".getBytes());
      fos.close();
    }
  }
View Full Code Here

            return ((NativeSocketChannel)channel).getFD();
        }

        if (FILE_DESCRIPTOR_FD != null) {
            FileDescriptor fd = getDescriptorFromChannel(channel);
            if (fd.valid()) {
                try {
                    return (Integer)FILE_DESCRIPTOR_FD.get(fd);
                } catch (Exception e) {
                    // failed to get
                }
View Full Code Here

     */
    @Test
    public void testGetFD() throws Exception {
        System.out.println("getFD");
        FileDescriptor result = instance.getFD();
        assertTrue(result.valid());
    }

    /**
     * Test of read method, of class OptimizedRandomAccessFile.
     */
 
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.