Package java.io

Examples of java.io.RandomAccessFile.readByte()


      Preconditions.checkState(open, "File closed");
      RandomAccessFile fileHandle = checkOut();
      boolean error = true;
      try {
        fileHandle.seek(offset);
        byte operation = fileHandle.readByte();
        Preconditions.checkState(operation == OP_RECORD,
            Integer.toHexString(operation));
        TransactionEventRecord record = doGet(fileHandle);
        if(!(record instanceof Put)) {
          Preconditions.checkState(false, "Record is " +
View Full Code Here


    public void test_writeByteI() throws IOException {
        // Test for method void java.io.RandomAccessFile.writeByte(int)
        RandomAccessFile raf = new java.io.RandomAccessFile(fileName, "rw");
        raf.writeByte(127);
        raf.seek(0);
        assertEquals("Incorrect byte read/written", 127, raf.readByte());
        raf.close();
    }

    /**
     * @tests java.io.RandomAccessFile#writeBytes(java.lang.String)
View Full Code Here

    public void test_readByte() throws IOException {
        // Test for method byte java.io.RandomAccessFile.readByte()
        RandomAccessFile raf = new java.io.RandomAccessFile(fileName, "rw");
        raf.writeByte(127);
        raf.seek(0);
        assertEquals("Incorrect bytes read/written", 127, raf.readByte());
        raf.close();
    }

    /**
     * @tests java.io.RandomAccessFile#readChar()
View Full Code Here

                            byte [] zfieNameBytes = new byte[zfieNameBytesLen];
                            raf.read(zfieNameBytes);
                            String eName = new String(zfieNameBytes, "UTF-8");

                            // Read isDir
                            boolean eIsDir = raf.readByte() == (byte)0 ? false : true;

                            // Read offset of bytes in the real Jar/Zip file
                            int eOffset = raf.readInt();

                            // Read size of the file in the real Jar/Zip file
View Full Code Here

                RandomAccessFile raf = getOrCreateRaf(Thread.currentThread(), location.getDataFileId());
                if (seekToLocation(raf, location)) {
                    long position = raf.getFilePointer();
                    location.setPointer(raf.readInt());
                    location.setSize(raf.readInt());
                    location.setType(raf.readByte());
                    if (location.getSize() > 0) {
                        location.setData(readLocationData(location, raf));
                        raf.seek(position);
                        return location;
                    } else {
View Full Code Here

                    long position = 0;
                    do {
                        position = raf.getFilePointer();
                        next.setPointer(raf.readInt());
                        next.setSize(raf.readInt());
                        next.setType(raf.readByte());
                        if (type != Location.ANY_RECORD_TYPE && next.getType() != type) {
                            raf.skipBytes(next.getSize() - Journal.HEADER_SIZE);
                        } else {
                            break;
                        }
View Full Code Here

                RandomAccessFile raf = getOrCreateRaf(Thread.currentThread(), location.getDataFileId());
                if (seekToLocation(raf, location)) {
                    long position = raf.getFilePointer();
                    location.setPointer(raf.readInt());
                    location.setSize(raf.readInt());
                    location.setType(raf.readByte());
                    if (location.getSize() > 0) {
                        location.setData(readLocationData(location, raf));
                        raf.seek(position);
                        return location;
                    } else {
View Full Code Here

                    long position = 0;
                    do {
                        position = raf.getFilePointer();
                        next.setPointer(raf.readInt());
                        next.setSize(raf.readInt());
                        next.setType(raf.readByte());
                        if (next.getType() != type) {
                            raf.skipBytes(next.getSize() - Journal.HEADER_SIZE);
                        } else {
                            break;
                        }
View Full Code Here

      Preconditions.checkState(open, "File closed");
      RandomAccessFile fileHandle = checkOut();
      boolean error = true;
      try {
        fileHandle.seek(offset);
        byte operation = fileHandle.readByte();
        Preconditions.checkState(operation == OP_RECORD);
        TransactionEventRecord record = TransactionEventRecord.
            fromDataInput(fileHandle);
        if(!(record instanceof Put)) {
          Preconditions.checkState(false, "Record is " +
View Full Code Here

     * @see org.apache.activemq.kaha.impl.data.DataFileReader#readDataItemSize(org.apache.activemq.kaha.impl.data.DataItem)
     */
    public synchronized byte readDataItemSize(DataItem item) throws IOException {
        RandomAccessFile file = dataManager.getDataFile(item).getRandomAccessFile();
        file.seek(item.getOffset()); // jump to the size field
        byte rc = file.readByte();
        item.setSize(file.readInt());
        return rc;
    }

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