Package java.nio.charset

Examples of java.nio.charset.Charset.newDecoder()


            return cbuf.toString();
        }
        catch( CharacterCodingException e )
        {
            Charset        latin1    = Charset.forName("ISO-8859-1");
            CharsetDecoder l1decoder = latin1.newDecoder();

            l1decoder.onMalformedInput( CodingErrorAction.REPORT );
            l1decoder.onUnmappableCharacter( CodingErrorAction.REPORT );

            try
View Full Code Here


  private volatile ActionAndServerEventListener eventHandler;

  public XmlSocketsChannel(String server, int port, String username,
      String password) throws RemoteException {
    Charset charset = Charset.forName("UTF-8");
    decoder = charset.newDecoder();
    try {
      socket = new Socket(server, port);
      socketWriter = new OutputStreamWriter(socket.getOutputStream());
    } catch (UnknownHostException exception) {
      throw new RemoteException("Exception opening socket.", exception);
View Full Code Here

  private final CharsetDecoder decoder;

  public SendPolicyRequest(String server, int port) throws IOException {
    Charset charset = Charset.forName("UTF-8");
    decoder = charset.newDecoder();
    try {
      socket = new Socket(server, port);
      socketWriter = new OutputStreamWriter(socket.getOutputStream());
    } catch (UnknownHostException exception) {
      throw new RemoteException("Exception opening socket.", exception);
View Full Code Here

    /* (non-Javadoc)
     * @see net.sf.jniosocket.core.ChatSocket#collectIncomingData(java.nio.ByteBuffer)
     */
    protected void collectIncomingData(ByteBuffer data) {
        Charset charset=Charset.forName("ISO-8859-1");
        CharsetDecoder decoder = charset.newDecoder();
        try {
            CharBuffer charBuffer = decoder.decode(data);
            System.out.print(charBuffer.array());
        } catch (CharacterCodingException cce) {
            System.out.println("Exception collection data");
View Full Code Here

    /* (non-Javadoc)
     * @see net.sf.jniosocket.core.ChatSocket#collectIncomingData(java.nio.ByteBuffer)
     */
    protected void collectIncomingData(ByteBuffer data) {
        Charset charset=Charset.forName("ISO-8859-1");
        CharsetDecoder decoder = charset.newDecoder();
        try {
            CharBuffer charBuffer = decoder.decode(data);
            System.out.print(charBuffer.array());
        } catch (CharacterCodingException cce) {
            System.out.println("Exception collection data");
View Full Code Here

            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;
View Full Code Here

            try {
                result = cache.getByteToCharConverter(javaCodeSetName);

                if (result == null) {
                    Charset tmpCharset = Charset.forName(javaCodeSetName);
                    result = tmpCharset.newDecoder();
                    cache.setConverter(javaCodeSetName, result);
                }

            } catch(IllegalCharsetNameException icne) {
                // This can only happen if one of our charset entries has
View Full Code Here

        Charset charset = Charset.forName("UTF-8");
        buf.clear();
        buf.putString("hello", charset.newEncoder());
        buf.put((byte) 0);
        buf.flip();
        assertEquals("hello", buf.getString(charset.newDecoder()));

        buf.clear();
        buf.putString("hello", charset.newEncoder());
        buf.flip();
        assertEquals("hello", buf.getString(charset.newDecoder()));
View Full Code Here

        assertEquals("hello", buf.getString(charset.newDecoder()));

        buf.clear();
        buf.putString("hello", charset.newEncoder());
        buf.flip();
        assertEquals("hello", buf.getString(charset.newDecoder()));

        decoder = Charset.forName("ISO-8859-1").newDecoder();
        buf.clear();
        buf.put((byte) 'A');
        buf.put((byte) 'B');
View Full Code Here

        Charset charset = Charset.forName("UTF-8");
        buf.clear();
        buf.putString("hello", charset.newEncoder());
        buf.put((byte) 0);
        buf.flip();
        Assert.assertEquals("hello", buf.getString(charset.newDecoder()));

        buf.clear();
        buf.putString("hello", charset.newEncoder());
        buf.flip();
        Assert.assertEquals("hello", buf.getString(charset.newDecoder()));
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.