code: public void writeData(long offset, ByteBuffer srcBuf) throws IOException {
          
          int len = srcBuf.remaining();
  
          if (len == 0) return;
  
          final long minSize = offset + len;
          if (getLengthOnDisk() < minSize) {
              setSize(minSize);
          }
          
          final long[] chain = fat.getChain(getStartCluster());
  
          int chainIdx = (int) (offset / clusterSize);
          
          if (offset % clusterSize != 0) {
              int clusOfs = (int) (offset % clusterSize);
              int size = Math.min(len,
                      (int) (clusterSize - (offset % clusterSize)));
              srcBuf.limit(srcBuf.position() + size);
              
              device.write(getDevOffset(chain[chainIdx], clusOfs), srcBuf);
              
              len -= size;
              chainIdx++;
          }
          
          while (len > 0) {
              int size = Math.min(clusterSize, len);
              srcBuf.limit(srcBuf.position() + size);
  
              device.write(getDevOffset(chain[chainIdx], 0), srcBuf);
  
              len -= size;
              chainIdx++;
          }
          
      }
docs: Writes data to this cluster chain, possibly growing the chain so it
  can store the additional data. When this method returns without throwing
  an exception, the buffer's {@link ByteBuffer#position() position} will
  equal it's {@link ByteBuffer#limit() limit}, and the limit will not
  have changed. This is not guaranteed if writing fails.
  
  @param offset the offset where to write the first byte from the buffer
  @param srcBuf the buffer to write to this {@code ClusterChain}
  @throws IOException on write error