Code example for RandomAccessFile

Methods: getFilePointer, seek, write

0
   * @param pos the position to alter 
   * @param newdata the data to modify 
   */ 
  public void setData(byte[] newdata, int pos) throws IOException
  { 
    long curpos = data.getFilePointer();
    data.seek(pos);
    data.write(newdata);
    data.seek(curpos);
  } 
 
  /**  
   * Writes the data to the output stream 
   */ 
  public void writeData(OutputStream out) throws IOException
  { 
		byte[] buffer = new byte[1024];
		int length = 0;
		data.seek(0);
		while ((length = data.read(buffer)) != -1)
		{