You need to overwrite the full 16 bytes. An example of how to do that would be:
ByteBuffer buf = ByteBuffer.allocate(16);
buf.put(value.getBytes("UTF-8"));
database.seek(offset);
database.write(buf.array());
This will write trailing zeroes after the record contents.
Note however that for each record you write, this involves two system calls which you can avoid if you use a memory mapping of the file. See FileChannel.map()
.