public synchronized void sync() throws IOException {
  if (needsSync) {
    BitSet bitSet=allocatedNodes;
    int bitSetLength=allocatedNodes.length();
    if (bitSetLength < allocatedNodes.size()) {
      bitSet=allocatedNodes.get(0,bitSetLength);
    }
    byte[] data=ByteArrayUtil.toByteArray(bitSet);
    nioFile.truncate(HEADER_LENGTH + data.length);
    nioFile.writeBytes(MAGIC_NUMBER,0);
    nioFile.writeByte(FILE_FORMAT_VERSION,MAGIC_NUMBER.length);
    nioFile.writeBytes(data,HEADER_LENGTH);
    needsSync=false;
  }
}

public synchronized void sync ( ) throws IOException { if ( needsSync ) { BitSet bitSet = allocatedNodes ; int bitSetLength = allocatedNodes . length ( ) ; if ( bitSetLength < allocatedNodes . size ( ) ) { bitSet = allocatedNodes . get ( 0 , bitSetLength ) ; } byte [ ] data = ByteArrayUtil . toByteArray ( bitSet ) ; nioFile . truncate ( HEADER_LENGTH + data . length ) ; nioFile . writeBytes ( MAGIC_NUMBER , 0 ) ; nioFile . writeByte ( FILE_FORMAT_VERSION , MAGIC_NUMBER . length ) ; nioFile . writeBytes ( data , HEADER_LENGTH ) ; needsSync = false ; } }
writes any changes that are cached in memory to disk .
