code: public final void save(final String[] comments, final boolean sortByKey) throws IOException, MergeException, LockingFailedException {
  
          try (final RandomAccessFileOutputStream out = new RandomAccessFileOutputStream(file, "rw");
                  final Writer writer = new OutputStreamWriter(new BufferedOutputStream(out), encoding)) {
              try (final FileLock lock = out.lock(tryLockMax, tryWaitMillis)) {
  
                  // TODO Anyone knows a better/faster solution?
                  // Just checking "file.lastModified()" failed here on a
                  // irregular base so always merging seems to be the best
                  // alternative...
                  merge(new RandomAccessFileInputStream(out));
                  out.seek(0);
                  out.resetCounter();
  
                  // Sort?
                  if (sortByKey) {
                      Collections.sort(props);
                  }
  
                  // Write the data to disk
                  final String lf = System.getProperty("line.separator");
  
                  // Write comment
                  for (int i = 0; i < comments.length; i++) {
                      writer.write("# ");
                      writer.write(comments[i]);
                      writer.write(lf);
                  }
  
                  // Save all values
                  for (int i = 0; i < props.size(); i++) {
                      final Property prop = props.get(i);
                      if (!prop.isDeleted()) {
                          writer.write(prop.toKeyValue());
                          writer.write(lf);
                          // Replace the property with the new status
                          props.set(i, new Property(prop.getKey(), prop.getValue(), prop.getValue()));
                      }
                  }
                  writer.flush();
                  out.truncate();
                  out.flush();
  
              }
          }
  
          // Remove all deleted entries
          for (int i = props.size() - 1; i >= 0; i--) {
              final Property prop = props.get(i);
              if (prop.isDeleted()) {
                  props.remove(i);
              }
          }
  
      }
docs: Save the content from memory to disk.
  
  @param comments
  Comments to prepend (Should not include the "#" comment sign - It will be prepended automatically).
  @param sortByKey
  Sort the properties by key before saving?
  
  @throws IOException
  Error writing the file.
  @throws MergeException
  One or more properties were modified concurrently.
  @throws LockingFailedException
  Locking the file failed.