Code example for RandomAccessFile

Methods: seek, write, writeByte, writeInt

0
    /** 
     * args: sectorNumber, data, length - write the chunk data to this RegionFile 
     */ 
    private void write(int par1, byte[] par2ArrayOfByte, int par3) throws IOException
    { 
        this.dataFile.seek((long)(par1 * 4096));
        this.dataFile.writeInt(par3 + 1);
        this.dataFile.writeByte(2);
        this.dataFile.write(par2ArrayOfByte, 0, par3);
    } 
 
    /** 
     * args: x, z - check region bounds 
     */ 
    private boolean outOfBounds(int par1, int par2)
    { 
        return par1 < 0 || par1 >= 32 || par2 < 0 || par2 >= 32;
    } 
 
    /** 
     * args: x, y - get chunk's offset in region file