Package java.io

Examples of java.io.RandomAccessFile.writeByte()


            fout.writeBoolean(head.endian); // Big Endian - should
            // match head.endian
            fout.writeShort(RpfHeader.HEADER_SECTION_LENGTH);
            fout.writeBytes("       A.TOC"); // has to be padded.
            fout.writeByte(head.neww);

            fout.writeBytes(head.standardNumber);
            if (head.standardNumber.length() < 15) {
                fout.writeBytes(createPadding(15 - head.standardNumber.length(),
                        false));
View Full Code Here


        try {
            RandomAccessFile raf = new RandomAccessFile(file, "rw");
            raf.seek(raf.length());
            for (String s: log) {
                raf.write(UTF8.getBytes(s));
                raf.writeByte(10);
            }
            log.clear();
        } catch (FileNotFoundException e) {
            Log.logException(e);
        } catch (IOException e) {
View Full Code Here

      });
      if (files != null && files.length > 0) {
        for (int j = 0; j < files.length; j++) {
          RandomAccessFile fileToCorrupt = new RandomAccessFile(files[0], "rw");
          fileToCorrupt.seek(50);
          fileToCorrupt.writeByte(234);
          fileToCorrupt.close();
        }
      }
    }
    Set<String> events;
View Full Code Here

     * @throws Exception if failed
     */
    @Test
    public void testReadUnsignedByte() throws Exception {
        RandomAccessFile file = file();
        file.writeByte(100);
        file.writeByte(200);
        file.seek(0);

        BufferedFileInput buf = manage(new BufferedFileInput(file, 256));
        assertThat(buf.readUnsignedByte(), is(100));
View Full Code Here

     */
    @Test
    public void testReadUnsignedByte() throws Exception {
        RandomAccessFile file = file();
        file.writeByte(100);
        file.writeByte(200);
        file.seek(0);

        BufferedFileInput buf = manage(new BufferedFileInput(file, 256));
        assertThat(buf.readUnsignedByte(), is(100));
        assertThat(buf.readUnsignedByte(), is(200));
View Full Code Here

            raf = getDescriptor();
            if ( offset >= raf.length() ) {
               // Grow the file
               long o = (fileHeader.headerSize + ((fileHeader.totalCount * 3) / 2) * fileHeader.pageSize) + (fileHeader.pageSize - 1);
               raf.seek(o);
               raf.writeByte(0);
            }
            raf.seek(offset);
            raf.write(data);
         }
         finally {
View Full Code Here

    RandomAccessFile raf = new RandomAccessFile(file,"rws");
    Random random = new Random();
    for (long i = 0; i < raf.length(); i++) {
      raf.seek(i);
      if (random.nextBoolean()) {
        raf.writeByte(random.nextInt());
      }
    }
    raf.close();
  }
 
View Full Code Here

                    (DbLsn.getFileOffset(lsn) + LogEntryHeader.FLAGS_OFFSET);
                file.seek(entryFlagsOffset);
                byte flags = file.readByte();
                byte newFlags = LogEntryHeader.makeInvisible(flags);
                file.seek(entryFlagsOffset);
                file.writeByte(newFlags);
            }
        } catch (IOException e) {
            throw new EnvironmentFailureException
                (envImpl, EnvironmentFailureReason.LOG_WRITE,
                 "Flipping invisibility in file " + fileNum, e);
View Full Code Here

     * @tests 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();
    }

View Full Code Here

     * @tests java.io.RandomAccessFile#readUnsignedByte()
     */
    public void test_readUnsignedByte() throws IOException {
        // Test for method int java.io.RandomAccessFile.readUnsignedByte()
        RandomAccessFile raf = new java.io.RandomAccessFile(fileName, "rw");
        raf.writeByte(-1);
        raf.seek(0);
        assertEquals("Incorrect byte read/written", 255, raf.readUnsignedByte());
        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.