Package net.morimekta.util.io
Class Utf8StreamWriter
- java.lang.Object
-
- java.io.Writer
-
- net.morimekta.util.io.Utf8StreamWriter
-
- All Implemented Interfaces:
java.io.Closeable
,java.io.Flushable
,java.lang.Appendable
,java.lang.AutoCloseable
public class Utf8StreamWriter extends java.io.Writer
Similar to java nativeOutputStreamWriter
, but locked to utf-8, and explicitly with no buffering whatsoever, with one exception only, which is catching surrogate pair chars.In order to make this writer more efficient, rather wrap the output stream in a BufferedOutputStream, which can handle all the byte-level buffering. E.g.:
Writer writer = new Utf8StreamWriter(new BufferedOutputStream(out));
-
-
Constructor Summary
Constructors Constructor Description Utf8StreamWriter(java.io.OutputStream out)
Utf8StreamWriter(java.io.OutputStream out, boolean strict)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
void
flush()
void
write(char[] chars, int off, int len)
-
-
-
Method Detail
-
write
public void write(char[] chars, int off, int len) throws java.io.IOException
- Specified by:
write
in classjava.io.Writer
- Throws:
java.io.IOException
-
flush
public void flush() throws java.io.IOException
- Specified by:
flush
in interfacejava.io.Flushable
- Specified by:
flush
in classjava.io.Writer
- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Specified by:
close
in classjava.io.Writer
- Throws:
java.io.IOException
-
-