Package java.io

Examples of java.io.FileDescriptor.sync()


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

        RandomAccessFile raf = new RandomAccessFile(f, "r");
        fd = raf.getFD();
        fd.sync();
        raf.close();
    }

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

      Date start = new Date();

      for (int index = 0; index < numberOfCalls; index++)
      {
        randomAccessFile.write(block);
        fileDescriptor.sync();
      }

      Date end = new Date();

      randomAccessFile.close();
View Full Code Here

                    descriptor = access.getFD();
                }
            }

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

    /**
 
View Full Code Here

                try {
                    FileDescriptor fd = fout.getFD();
                    fout.write((refValue + "\n").getBytes(CHARSET));
                    fout.flush();
                    // force change to be persisted to disk
                    fd.sync();
                } finally {
                    fout.close();
                }
            }
        } catch (IOException e) {
View Full Code Here

                    descriptor = access.getFD();
                }
            }

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

    /**
 
View Full Code Here

                out.writeInt(bytes.remaining());
                out.write(bytes.array(),bytes.position()+bytes.arrayOffset(),bytes.remaining());
                ++count;
            }
            out.flush();
            fd.sync();
            out.close();
            if (!tmpFile.renameTo(savedCachePath))
                throw new IOException("Unable to rename cache to " + savedCachePath);
            if (logger.isDebugEnabled())
                logger.debug("saved " + count + " keys in " + (System.currentTimeMillis() - start) + " ms from " + msgSuffix);
View Full Code Here

/*  753 */           if (synchronousWrites())
/*      */           {
/*  757 */             ofile.flush();
/*      */
/*  759 */             FileDescriptor fileDesc = ofile.getFD();
/*  760 */             fileDesc.sync();
/*      */           }
/*      */         }
/*      */         catch (SyncFailedException e)
/*      */         {
/*  765 */           closeAndUnlock(fd, null, ofile);
View Full Code Here

                out.writeInt(bytes.remaining());
                out.write(bytes.array(),bytes.position()+bytes.arrayOffset(),bytes.remaining());
                ++count;
            }
            out.flush();
            fd.sync();
            out.close();
            if (!tmpFile.renameTo(savedCachePath))
                throw new IOException("Unable to rename cache to " + savedCachePath);
            if (logger.isDebugEnabled())
                logger.debug("saved " + count + " keys in " + (System.currentTimeMillis() - start) + " ms from" + msgSuffix);
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.