publicstaticvoid main(String args[]) throws Exception {
CharsetEncoder enc = Charset.forName("ISO2022JP").newEncoder();
CharBuffer cb = CharBuffer.wrap(inputChars);
ByteBuffer bb = ByteBuffer.wrap(outputBuff);
CoderResult cr = enc.encode(cb, bb, false); if (!cr.isOverflow()) thrownew Exception("Expected CodeResult.OVERFLOW was not returned"); for (int i = 0; i < expectedBytes1.length; ++i) { //System.out.println(expectedBytes1[i] + ":" + outputBuff[i]); if (expectedBytes1[i] != outputBuff[i]) { thrownew Exception("Output bytes does not match at first conversion");
}
} int nci = cb.position(); if (nci != expectedBytes1.length) thrownew Exception("Output length does not match at first conversion");
bb.clear();
cr = enc.encode(cb, bb, true);
enc.flush(bb); //System.out.println(ret + "," + expectedBytes2.length);
bb.flip(); int len = bb.remaining(); if (len != expectedBytes2.length) thrownew Exception("Output length does not match at second conversion"); for (int i = 0; i < expectedBytes2.length; ++i) { //System.out.println(expectedBytes2[i] + ":" + outputBuff[i]); if (expectedBytes2[i] != outputBuff[i]) { thrownew Exception("Output bytes does not match at second conversion");
}
}
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.