Package java.io

Examples of java.io.RandomAccessFile.readByte()


    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


    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_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

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

                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

    tempFile.seek(0);
    // Verify every 10th byte is actually a NOOP
    for(int i = 0; i < 5000; i+=10) {
      tempFile.seek(i);
      Assert.assertEquals(LogFile.OP_NOOP, tempFile.readByte());
    }

  }

  @Test
View Full Code Here

    final int offset = ptr.getOffset();
    LogFile.OperationRecordUpdater updater = new LogFile
      .OperationRecordUpdater(dataFile);
    updater.markRecordAsNoop(offset);
    RandomAccessFile fileReader = new RandomAccessFile(dataFile, "rw");
    Assert.assertEquals(LogFile.OP_NOOP, fileReader.readByte());
  }

  @Test
  public void testGroupCommit() throws Exception {
    final FlumeEvent eventIn = TestUtils.newPersistableEvent(250);
View Full Code Here

      Preconditions.checkState(open, "File closed");
      RandomAccessFile fileHandle = checkOut();
      boolean error = true;
      try {
        fileHandle.seek(offset);
        byte operation = fileHandle.readByte();
        if(operation == OP_NOOP) {
          throw new NoopRecordException("No op record found. Corrupt record " +
            "may have been repaired by File Channel Integrity tool");
        }
        Preconditions.checkState(operation == OP_RECORD,
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.