package stexfires.io;

import stexfires.core.Record;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.OpenOption;
import java.nio.file.Path;
import java.util.Objects;

/**
 * @author Mathias Kalb
 * @since 0.1
 */
public class BaseRecordFile<W extends Record, R extends W> implements ReadableRecordFile<R>, WritableRecordFile<W> {

    protected final Path path;

    public BaseRecordFile(final Path path) {
        Objects.requireNonNull(path);
        this.path = path;
    }

    @Override
    public final Path getPath() {
        return path;
    }

    @Override
    public ReadableRecordProducer<R> openProducer() throws IOException {
        throw new UnsupportedOperationException();
    }

    @Override
    public WritableRecordConsumer<W> openConsumer() throws IOException {
        throw new UnsupportedOperationException();
    }

    protected BufferedWriter newBufferedWriter(Charset charset, OpenOption... options) throws IOException {
        return Files.newBufferedWriter(path, charset, options);
    }

    protected BufferedReader newBufferedReader(Charset charset) throws IOException {
        return Files.newBufferedReader(path, charset);
    }

}

@@ -153,27 +153,102 @@
 ava.
-nio.charset.Charset
+io.OutputStreamWriter;%0Aimport java.nio.charset.Charset;%0Aimport java.nio.charset.CharsetEncoder
 ;%0Aim
@@ -1209,32 +1209,274 @@
 ptions);%0A    %7D%0A%0A
+    protected BufferedWriter newBufferedWriter(CharsetEncoder charsetEncoder, OpenOption... options) throws IOException %7B%0A        return new BufferedWriter(new OutputStreamWriter(Files.newOutputStream(path, options), charsetEncoder));%0A    %7D%0A%0A
     protected Bu

Add new method newBufferedWriter with a CharsetEncoder