List of usage examples for java.nio.charset CoderResult isUnmappable
public boolean isUnmappable()
From source file:org.openbel.framework.ws.utils.Converter.java
private static Byte encode(final CharsetEncoder encoder, final char c) { encoder.reset();//from w w w .j a va 2s.com if (!encoder.canEncode(c)) { return null; } encoder.reset(); ByteBuffer buffer = ByteBuffer.allocate(1); CharBuffer charBuffer = CharBuffer.allocate(1).put(c); charBuffer.flip(); CoderResult result = null; result = encoder.encode(charBuffer, buffer, false); if (!result.isUnderflow()) { return null; } result = encoder.encode(charBuffer, buffer, true); if (result.isMalformed() || result.isUnmappable()) { return null; } result = encoder.flush(buffer); if (!result.isUnderflow()) { return null; } buffer.flip(); return buffer.get(0); }