Package java.io

Examples of java.io.RandomAccessFile.readLong()


    timestamp = 0;
    RandomAccessFile fileHandle = null;
    try {
      fileHandle = new RandomAccessFile(file, "r");
      fileHandle.seek(OFFSET_TIMESTAMP);
      timestamp = fileHandle.readLong();
    } catch(EOFException e) {
      // no checkpoint taken
    } catch (FileNotFoundException e) {
      // no checkpoint taken
    } finally {
View Full Code Here


            // to get as close as possible to the last written record...
            while (raf.getFilePointer() < raf.length()) {
                int headerSize = 12; // 8 for long, 4 for int...
                waitToRead(raf, headerSize);

                long id = raf.readLong();
                int entrySize = raf.readInt();
                waitToRead(raf, entrySize);

                if ((id >= fromId) && (id <= toId)) {
                    byte[] buffer = new byte[entrySize];
View Full Code Here

    {
        try (RandomAccessFile raf = new RandomAccessFile(file, "r"))
        {
            assert raf.getFilePointer() == 0;
            int version = raf.readInt();
            long id = raf.readLong();
            int crc = raf.readInt();
            PureJavaCrc32 checkcrc = new PureJavaCrc32();
            checkcrc.updateInt(version);
            checkcrc.updateInt((int) (id & 0xFFFFFFFFL));
            checkcrc.updateInt((int) (id >>> 32));
View Full Code Here

            dest.write(buffer);
        }

        dest.seek(DataFileCache.LONG_FREE_POS_POS);

        long length = dest.readLong();

        JavaSystem.setRAFileLength(dest, length);
        source.close();
        dest.close();
    }
View Full Code Here

    {
        try (RandomAccessFile raf = new RandomAccessFile(file, "r"))
        {
            assert raf.getFilePointer() == 0;
            int version = raf.readInt();
            long id = raf.readLong();
            int crc = raf.readInt();
            PureJavaCrc32 checkcrc = new PureJavaCrc32();
            checkcrc.updateInt(version);
            checkcrc.updateInt((int) (id & 0xFFFFFFFFL));
            checkcrc.updateInt((int) (id >>> 32));
View Full Code Here

            long size = chksumRdr.length();
            int chunk = 0;
           
            while ( chksumRdr.getFilePointer() != size )
            {
                long value = chksumRdr.readLong();
                long key = ChecksumManager.key(fId, ++chunk);
                chksums_.put(key, value);
            }
        }
    }
View Full Code Here

    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

    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

    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

    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

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.