cdm/src/main/java/ucar/unidata/io/RandomAccessFile.java
public void write(int b) throws IOException {

    // If the file position is within the block of data...
    if (filePosition < dataEnd) {
      int pos = (int) (filePosition - bufferStart);
      buffer[pos] = (byte) b;
      bufferModified = true;
      filePosition++;

      // ...or (assuming that seek will not allow the file pointer
      // to move beyond the end of the file) get the correct block of
      // data...
    } else {

      // If there is room in the buffer, expand it...
      if (dataSize != buffer.length) {
        int pos = (int) (filePosition - bufferStart);
        buffer[pos] = (byte) b;
        bufferModified = true;
        filePosition++;
        dataSize++;
        dataEnd++;

        // ...or do another seek to get a new buffer, and start again...
      } else {
        seek(filePosition);
        write(b);
      }
    }
  }
public void write(int b) throws IOException {

    // If the file position is within the block of data...
    if (filePosition < dataEnd) {
      int pos = (int) (filePosition - bufferStart);
      buffer[pos] = (byte) b;
      bufferModified = true;
      filePosition++;

      // ...or (assuming that seek will not allow the file pointer
      // to move beyond the end of the file) get the correct block of
      // data...
    } else {

      // If there is room in the buffer, expand it...
      if (dataSize != buffer.length) {
        int pos = (int) (filePosition - bufferStart);
        buffer[pos] = (byte) b;
        bufferModified = true;
        filePosition++;
        dataSize++;
        dataEnd++;

        // ...or do another seek to get a new buffer, and start again...
      } else {
        seek(filePosition);
        write(b);
      }
    }
  }
Write a byte to the file. If the file has not been opened for
writing, an IOException will be raised only when an attempt is
made to write the buffer to the file.
<p/>
Caveat: the effects of seek( )ing beyond the end of the file are
undefined.

@param b write this byte
@throws IOException if an I/O error occurrs.