Package java.io

Examples of java.io.FileDescriptor.sync()


        while (true) {
            if (write.getFilePointer() >= fileSize) {
                break;
            }
            write.writeBytes(i + "\r\n");
            fd.sync();
            out.writeInt(i);
            out.flush();
            i++;
        }
        write.close();
View Full Code Here


        int i = 0;
        if (flush) {
            for (;; i++) {
                file.seek(0);
                file.write(data);
                fd.sync();
                if ((i & 15) == 0) {
                    long time = System.currentTimeMillis() - start;
                    if (time > 5000) {
                        break;
                    }
View Full Code Here

     */
    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

      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

        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
View Full Code Here

        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();
View Full Code Here

        assertEquals("Bytes were not written after sync", length, fis
                .available());
       
        RandomAccessFile raf = new RandomAccessFile(f, "r");
        fd = raf.getFD();
        fd.sync();
        raf.close();
  }

  /**
   * @tests java.io.FileDescriptor#valid()
View Full Code Here

    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

                    descriptor = access.getFD();
                }
            }

            if (descriptor != null) {
                descriptor.sync();
            }
        }
    }

    /**
 
View Full Code Here

                    descriptor = access.getFD();
                }
            }

            if (descriptor != null) {
                descriptor.sync();
            }
        }
    }

    /**
 
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.