fork(1) download
  1. import java.nio.ByteBuffer;
  2. import java.nio.charset.CharacterCodingException;
  3. import java.nio.charset.Charset;
  4. import java.nio.charset.CharsetDecoder;
  5.  
  6. class Test {
  7. public static void main(String[] args) throws CharacterCodingException {
  8. ByteBuffer buffer = ByteBuffer.allocate(8);
  9. buffer.putInt(0x80);
  10. buffer.putInt(0x81);
  11. buffer.position(0);
  12. Charset charset = Charset.forName("IBM1098");
  13. CharsetDecoder decoder = charset.newDecoder();
  14. decoder.decode(buffer);
  15. }
  16. }
  17.  
Runtime error #stdin #stdout #stderr 0.09s 380480KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Exception in thread "main" java.nio.charset.UnmappableCharacterException: Input length = 1
	at java.nio.charset.CoderResult.throwException(CoderResult.java:278)
	at java.nio.charset.CharsetDecoder.decode(CharsetDecoder.java:798)
	at Test.main(Main.java:14)