void () { if (! myDirty) return; try{ final BufferExposingByteArrayOutputStream bos = new BufferExposingByteArrayOutputStream(); final DataOutput out = new DataOutputStream(bos); out.writeInt(myMap.size()); for (Map.Entry<KeyWrapper<K>, V> entry : myMap.entrySet()) { myKeyDescriptor.save(out, entry.getKey().myKey); myValueExternalizer.save(out, entry.getValue()); } FileUtil.writeToFile(myFile, bos.getInternalBuffer(), 0, bos.size()); } catch (IOException e) { LOG.error(e); } finally { myDirty = false; } }