Package java.nio.charset

Examples of java.nio.charset.CharacterCodingException


                        continue;
                    }

                    boolean valid = ((c <= decoding.length) && (decoding[c] >= 0));
                    if (!valid && CodingErrorAction.REPORT.equals(unmappableAction)) {
                        throw new CharacterCodingException();
                    }
                    if (valid || CodingErrorAction.REPLACE.equals(unmappableAction)) {
                        // Support "replace" by returning a zero byte
                        chars[count] = valid ? decoding[c] : 0;
                        count++;
View Full Code Here


* Test CharacterCodingException
*/
public class CharacterCodingExceptionTest extends TestCase {

  public void testConstructor() {
    CharacterCodingException ex = new CharacterCodingException();
    assertTrue(ex instanceof IOException);
    assertNull(ex.getCause());
    assertNull(ex.getMessage());
  }
View Full Code Here

    /**
     * @tests serialization/deserialization compatibility.
     */
    public void testSerializationSelf() throws Exception {

        SerializationTest.verifySelf(new CharacterCodingException());
    }
View Full Code Here

    /**
     * @tests serialization/deserialization compatibility with RI.
     */
    public void testSerializationCompatibility() throws Exception {
        SerializationTest.verifyGolden(this, new CharacterCodingException());

    }
View Full Code Here

      } catch (CharacterCodingException e) {
        b.reset();
      }
    }

    throw new CharacterCodingException();
  }
View Full Code Here

      } catch (CharacterCodingException e) {
        b.reset();
      }
    }

    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

      } catch (CharacterCodingException e) {
        b.reset();
      }
    }

    throw new CharacterCodingException();
  }
View Full Code Here

    public int read() throws IOException {
        int rv = stream.read();
        if (rv < 0x80) {
            return rv;
        } else {
            throw new CharacterCodingException();
        }
    }
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.