Code example for RandomAccessFile

Methods: close, readFully, seek, skipBytes, writeBytes

0
     * @tests java.io.RandomAccessFile#skipBytes(int) 
     */ 
    public void test_skipBytesI() throws IOException { 
        // Test for method int java.io.RandomAccessFile.skipBytes(int) 
        byte[] buf = new byte[5];
        RandomAccessFile raf = new java.io.RandomAccessFile(fileName, "rw");
        raf.writeBytes("HelloWorld");
        raf.seek(0);
        raf.skipBytes(5);
        raf.readFully(buf);
        assertEquals("Failed to skip bytes", "World", new String(buf, 0, 5, "UTF-8"));
        raf.close();
    } 
 
    /** 
     * @tests java.io.RandomAccessFile#write(byte[]) 
     */ 
    public void test_write$B() throws IOException { 
        // Test for method void java.io.RandomAccessFile.write(byte []) 
        RandomAccessFile raf = new java.io.RandomAccessFile(fileName, "rw");