@@ -0,0 +1,2013 @@
+package com.wizzardo.tools.misc;%0A%0Aimport com.wizzardo.tools.reflection.StringReflection;%0A%0Aimport java.io.IOException;%0Aimport java.io.OutputStream;%0Aimport java.io.Writer;%0A%0A/**%0A * Created by wizzardo on 31.08.15.%0A */%0Apublic class UTF8Writer extends Writer %7B%0A    private static final byte%5B%5D CHARS_TRUE = new byte%5B%5D%7B't', 'r', 'u', 'e'%7D;%0A    private static final byte%5B%5D CHARS_FALSE = new byte%5B%5D%7B'f', 'a', 'l', 's', 'e'%7D;%0A    private static final byte%5B%5D CHARS_NULL = new byte%5B%5D%7B'n', 'u', 'l', 'l'%7D;%0A%0A    protected OutputStream out;%0A    protected int batchSize = 1024;%0A    protected byte%5B%5D bytes = new byte%5BbatchSize * 4%5D;%0A%0A    public UTF8Writer(OutputStream out) %7B%0A        this.out = out;%0A    %7D%0A%0A    @Override%0A    public void write(char%5B%5D chars, int off, int len) throws IOException %7B%0A        int limit = len + off;%0A        for (int i = off; i %3C limit; i += batchSize) %7B%0A            int l = UTF8.encode(chars, off, Math.min(off - limit, batchSize), bytes);%0A            out.write(bytes, 0, l);%0A        %7D%0A    %7D%0A%0A    public void write(int i) throws IOException %7B%0A        int l = NumberToChars.toChars(i, bytes, 0);%0A        out.write(bytes, 0, l);%0A    %7D%0A%0A    public void write(long i) throws IOException %7B%0A        int l = NumberToChars.toChars(i, bytes, 0);%0A        out.write(bytes, 0, l);%0A    %7D%0A%0A    public void write(String s) throws IOException %7B%0A        if (s == null)%0A            out.write(CHARS_NULL);%0A        else%0A            write(s, 0, s.length());%0A    %7D%0A%0A    public void write(String s, int off, int l) throws IOException %7B%0A        int offset = StringReflection.offset(s) + off;%0A        char%5B%5D chars = StringReflection.chars(s);%0A        write(chars, offset, l);%0A    %7D%0A%0A    public void write(boolean b) throws IOException %7B%0A        if (b)%0A            out.write(CHARS_TRUE, 0, 4);%0A        else%0A            out.write(CHARS_FALSE, 0, 5);%0A    %7D%0A%0A%0A    @Override%0A    public void flush() throws IOException %7B%0A        out.flush();%0A    %7D%0A%0A    @Override%0A    public void close() throws IOException %7B%0A        flush();%0A    %7D%0A%7D%0A

add simple UTF8Writer