11 import java.io.CharConversionException;
12 import java.io.IOException;
13 import java.io.Writer;
14 import java.nio.ByteBuffer;
59 throw new IllegalStateException(
"Writer not closed or reset");
72 public void write(
char c)
throws IOException {
73 if ((c < 0xd800) || (c > 0xdfff)) {
75 }
else if (c < 0xdc00) {
92 public void write(
int code)
throws IOException {
93 if ((code & 0xffffff80) == 0) {
100 private void write2(
int c)
throws IOException {
101 if ((c & 0xfffff800) == 0) {
104 }
else if ((c & 0xffff0000) == 0) {
106 _byteBuffer.put((
byte) (0x80 | ((c >> 6) & 0x3f)));
108 }
else if ((c & 0xff200000) == 0) {
110 _byteBuffer.put((
byte) (0x80 | ((c >> 12) & 0x3f)));
111 _byteBuffer.put((
byte) (0x80 | ((c >> 6) & 0x3f)));
113 }
else if ((c & 0xf4000000) == 0) {
115 _byteBuffer.put((
byte) (0x80 | ((c >> 18) & 0x3f)));
116 _byteBuffer.put((
byte) (0x80 | ((c >> 12) & 0x3f)));
117 _byteBuffer.put((
byte) (0x80 | ((c >> 6) & 0x3f)));
119 }
else if ((c & 0x80000000) == 0) {
121 _byteBuffer.put((
byte) (0x80 | ((c >> 24) & 0x3f)));
122 _byteBuffer.put((
byte) (0x80 | ((c >> 18) & 0x3f)));
123 _byteBuffer.put((
byte) (0x80 | ((c >> 12) & 0x3F)));
124 _byteBuffer.put((
byte) (0x80 | ((c >> 6) & 0x3F)));
127 throw new CharConversionException(
"Illegal character U+"
128 + Integer.toHexString(c));
140 public void write(
char cbuf[],
int off,
int len)
throws IOException {
141 final int off_plus_len = off + len;
142 for (
int i = off; i < off_plus_len;) {
160 public void write(String str,
int off,
int len)
throws IOException {
161 final int off_plus_len = off + len;
162 for (
int i = off; i < off_plus_len;) {
163 char c = str.charAt(i++);
178 public void write(CharSequence csq)
throws IOException {
179 final int length = csq.length();
180 for (
int i = 0; i < length;) {
181 char c = csq.charAt(i++);
196 public void flush() throws IOException {
197 if (
_byteBuffer ==
null) {
throw new IOException(
"Writer closed"); }
205 public void close() throws IOException {