Package java.nio.charset

Examples of java.nio.charset.CharacterCodingException


        if (charset == null || "".equals(charset)) {
            charSet = Charset.defaultCharset();
        } else if (Charset.isSupported(charset)) {
            charSet = Charset.forName(charset);
        } else {
            CharacterCodingException e = new CharacterCodingException();
            e.initCause(new UnsupportedCharsetException(charset));
            throw e;
        }

        CharsetDecoder decoder = charSet.newDecoder();
        CharBuffer charBuffer = null;
        try {
            charBuffer = decoder.decode(byteBuffer);
        } catch(CharacterCodingException cce) {
            throw cce;
        } catch(Throwable t) {
            CharacterCodingException e = new CharacterCodingException();
            e.initCause(t);
            throw e;
        }
        char[] result = toCharArray(charBuffer);
        clear(byteBuffer);
        clear(charBuffer);
View Full Code Here


        if (strCharset == null || "".equals(strCharset)) {
            charSet = Charset.defaultCharset();
        } else if (Charset.isSupported(strCharset)) {
            charSet = Charset.forName(strCharset);
        } else {
            CharacterCodingException e = new CharacterCodingException();
            e.initCause(new UnsupportedCharsetException(strCharset));
            throw e;
        }

        CharsetEncoder encoder = charSet.newEncoder();
        ByteBuffer byteBuffer = null;
        try {
            byteBuffer = encoder.encode(charBuffer);
        } catch(CharacterCodingException cce) {
            throw cce;
        } catch(Throwable t) {
            CharacterCodingException e = new CharacterCodingException();
            e.initCause(t);
            throw e;
        }

        byte[] result = new byte[byteBuffer.remaining()];
        byteBuffer.get(result);
View Full Code Here

      appendable.append('%');
      appendable.append(ALPHABET[(c0 & 0xF0) >> 4]);
      appendable.append(ALPHABET[c0 & 0xF]);
    } else {
      // Java primitive type cannot handle more than 16 bits
      throw new CharacterCodingException();
    }
  }
View Full Code Here

        if (charset == null || "".equals(charset)) {
            charSet = Charset.defaultCharset();
        } else if (Charset.isSupported(charset)) {
            charSet = Charset.forName(charset);
        } else {
            CharacterCodingException e = new CharacterCodingException();
            e.initCause(new UnsupportedCharsetException(charset));
            throw e;
        }

        CharsetDecoder decoder = charSet.newDecoder();
        CharBuffer charBuffer = null;
        try {
            charBuffer = decoder.decode(byteBuffer);
        } catch(CharacterCodingException cce) {
            throw cce;
        } catch(Throwable t) {
            CharacterCodingException e = new CharacterCodingException();
            e.initCause(t);
            throw e;
        }
        char[] result = (char[])charBuffer.array().clone();
        clear(byteBuffer);
        clear(charBuffer);
View Full Code Here

        if (strCharset == null || "".equals(strCharset)) {
            charSet = Charset.defaultCharset();
        } else if (Charset.isSupported(strCharset)) {
            charSet = Charset.forName(strCharset);
        } else {
            CharacterCodingException e = new CharacterCodingException();
            e.initCause(new UnsupportedCharsetException(strCharset));
            throw e;
        }

        CharsetEncoder encoder = charSet.newEncoder();
        ByteBuffer byteBuffer = null;
        try {
            byteBuffer = encoder.encode(charBuffer);
        } catch(CharacterCodingException cce) {
            throw cce;
        } catch(Throwable t) {
            CharacterCodingException e = new CharacterCodingException();
            e.initCause(t);
            throw e;
        }

        byte[] result = new byte[byteBuffer.remaining()];
        byteBuffer.get(result);
View Full Code Here

TOP

Related Classes of java.nio.charset.CharacterCodingException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.