package de.gurkenlabs.litiengine.configuration;

import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Collections;
import java.util.Enumeration;
import java.util.Properties;
import java.util.TreeSet;

public class CleanProperties extends Properties {
  private static final long serialVersionUID = 7567765340218227372L;

  @Override
  public synchronized Enumeration<Object> keys() {
    return Collections.enumeration(new TreeSet<>(super.keySet()));
  }

  @Override
  public void store(final OutputStream out, final String comments) throws IOException {
    super.store(new StripFirstLineStream(out), null);
  }

  private static class StripFirstLineStream extends FilterOutputStream {
    private boolean firstlineseen = false;

    public StripFirstLineStream(final OutputStream out) {
      super(out);
    }

    @Override
    public void write(final int b) throws IOException {
      if (firstlineseen) {
        super.write(b);
      } else if (b == '\n') {
        firstlineseen = true;
      }
    }
  }
}

@@ -969,21 +969,19 @@
         
-super
+out
 .write(b
@@ -1056,15 +1056,285 @@
  %7D%0A    %7D
+%0A%0A    @Override%0A    public void write(byte%5B%5D b, int off, int len) %7B%0A      while (!firstlineseen) %7B%0A        if (b%5Boff++%5D == '%5Cn') %7B%0A          firstlineseen = true;%0A        %7D%0A        if (--len == 0) %7B%0A          return;%0A        %7D%0A      %7D%0A      out.write(b, off, len);%0A    %7D
 %0A  %7D%0A%7D%0A

Implement write(byte[],int,int)