Package java.io

Examples of java.io.RandomAccessFile.writeLong()


    void markCheckpoint(long currentPosition, long logWriteOrderID)
        throws IOException {
      RandomAccessFile writeFileHandle = getFileHandle();
      writeFileHandle.seek(OFFSET_CHECKPOINT);
      writeFileHandle.writeLong(currentPosition);
      writeFileHandle.writeLong(logWriteOrderID);
      writeFileHandle.getChannel().force(true);
      LOGGER.info("Noted checkpoint for file: " + getFile() + ", id: "
          + getLogFileID() + ", checkpoint position: " + currentPosition
          + ", logWriteOrderID: " + logWriteOrderID);
View Full Code Here


      super(file, logFileID, maxFileSize, null);
      RandomAccessFile writeFileHandle = getFileHandle();
      writeFileHandle.writeInt(getVersion());
      writeFileHandle.writeInt(logFileID);
      // checkpoint marker
      writeFileHandle.writeLong(0L);
      // timestamp placeholder
      writeFileHandle.writeLong(0L);
      getFileChannel().force(true);

    }
View Full Code Here

      writeFileHandle.writeInt(getVersion());
      writeFileHandle.writeInt(logFileID);
      // checkpoint marker
      writeFileHandle.writeLong(0L);
      // timestamp placeholder
      writeFileHandle.writeLong(0L);
      getFileChannel().force(true);

    }
    @Override
    int getVersion() {
View Full Code Here

    }
    RandomAccessFile checkpointFileHandle =
        new RandomAccessFile(checkpointFile, "rw");
    try {
      checkpointFileHandle.seek(INDEX_VERSION * Serialization.SIZE_OF_LONG);
      checkpointFileHandle.writeLong(Serialization.VERSION_3);
      checkpointFileHandle.getChannel().force(true);
    } finally {
      try {
        checkpointFileHandle.close();
      } catch (IOException e) {
View Full Code Here

     * @tests java.io.RandomAccessFile#readLong()
     */
    public void test_readLong() throws IOException {
        // Test for method long java.io.RandomAccessFile.readLong()
        RandomAccessFile raf = new java.io.RandomAccessFile(fileName, "rw");
        raf.writeLong(Long.MAX_VALUE);
        raf.seek(0);
        assertEquals("Incorrect long read/written", Long.MAX_VALUE, raf
                .readLong());
        raf.close();
    }
View Full Code Here

     * @tests java.io.RandomAccessFile#writeLong(long)
     */
    public void test_writeLongJ() throws IOException {
        // Test for method void java.io.RandomAccessFile.writeLong(long)
        RandomAccessFile raf = new java.io.RandomAccessFile(fileName, "rw");
        raf.writeLong(Long.MAX_VALUE);
        raf.seek(0);
        assertEquals("Incorrect long read/written", Long.MAX_VALUE, raf
                .readLong());
        raf.close();
    }
View Full Code Here

        RandomAccessFile raf = null;
        long writtenSoFar = 0;
        try {
            raf = new RandomAccessFile(indexFile, "rw");

            raf.writeLong(zipFileLastModified);
            writtenSoFar += 8;

            List<DirectoryEntry> directoriesToWrite = new ArrayList<DirectoryEntry>();
            Map<RelativeDirectory, Long> offsets = new HashMap<RelativeDirectory, Long>();
            raf.writeInt(directories.keySet().size());
View Full Code Here

                offsets.put(dirName, new Long(writtenSoFar));

                // Write the offset of the file's data in the dir
                dirEntry.writtenOffsetOffset = 0L;
                raf.writeLong(0L);
                writtenSoFar += 8;
            }

            for (DirectoryEntry de : directoriesToWrite) {
                // Fix up the offset in the directory table
View Full Code Here

                // Fix up the offset in the directory table
                long currFP = raf.getFilePointer();

                long offsetOffset = offsets.get(de.dirName).longValue();
                raf.seek(offsetOffset);
                raf.writeLong(writtenSoFar);

                raf.seek(currFP);

                // Now write each of the files in the DirectoryEntry
                List<Entry> list = de.getEntriesAsCollection();
View Full Code Here

                    // Write compressed size of the file in the real Jar/Zip file
                    raf.writeInt(zfie.compressedSize);
                    writtenSoFar += 4;

                    // Write java time stamp of the file in the real Jar/Zip file
                    raf.writeLong(zfie.getLastModified());
                    writtenSoFar += 8;
                }
            }
        } catch (Throwable t) {
            // Do nothing
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.