Package java.nio

Examples of java.nio.CharBuffer.array()


    if (ioifc.bytesRead() > 0) {
      tmpBuffer.flip();
      CharBuffer cb = coder.decode(tmpBuffer);
      tmpBuffer.clear();
      if (cb != null) {
        System.out.print(new String(cb.array()));
      } // end of if (cb != null)
    } // end of if (socketIO.bytesRead() > 0)
    reader.addIOInterface(ioifc);
  }
View Full Code Here


    if (ioifc.bytesRead() > 0) {
      tmpBuffer.flip();
      CharBuffer cb = coder.decode(tmpBuffer);
      tmpBuffer.clear();
      if (cb != null) {
        System.out.print(new String(cb.array()));
      } // end of if (cb != null)
    } // end of if (socketIO.bytesRead() > 0)
    reader.addIOInterface(ioifc);
  }
View Full Code Here

            CharBuffer decodedBuffer = decoder.decode(
                    ByteBuffer.wrap(_byteArrayOutputStream.getInnerArray(),
                            0,_byteArrayOutputStream.getInnerCount()));
            if (decodedBuffer.hasArray())
            {
                out.write(decodedBuffer.array());
            }
        }

        public void reset()
        {
View Full Code Here

        // new String(byte[], int, int, Charset) takes a defensive copy of the
        // entire byte array. This is expensive if only a small subset of the
        // bytes will be used. The code below is from Apache Harmony.
        CharBuffer cb;
        cb = charset.decode(ByteBuffer.wrap(buff, start, end-start));
        return new String(cb.array(), cb.arrayOffset(), cb.length());
    }

    public int getInt()
    {
        return Ascii.parseInt(buff, start,end-start);
View Full Code Here

            CharsetDecoder decoder = charset.newDecoder();
            CharBuffer decodedBuffer = decoder.decode(
                    ByteBuffer.wrap(_byteArrayOutputStream.getInnerArray(),
                            0,_byteArrayOutputStream.getInnerCount()));
            if (decodedBuffer.hasArray()){
                out.write(decodedBuffer.array());
            }
        }

        public void reset()
        {
View Full Code Here

            CharBuffer decodedBuffer = decoder.decode(
                    ByteBuffer.wrap(_byteArrayOutputStream.getInnerArray(),
                            0,_byteArrayOutputStream.getInnerCount()));
            if (decodedBuffer.hasArray())
            {
                out.write(decodedBuffer.array());
            }
        }

        public void reset()
        {
View Full Code Here

    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");
            cce.printStackTrace();
        }
    }
View Full Code Here

    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");
            cce.printStackTrace();
        }
    }
View Full Code Here

        } catch(Throwable t) {
            CharacterCodingException e = new CharacterCodingException();
            e.initCause(t);
            throw e;
        }
        char[] result = (char[])charBuffer.array().clone();
        clear(byteBuffer);
        clear(charBuffer);

        return result;
    }
View Full Code Here

      segment=i.next();
      assertEquals(StartTagType.SERVER_COMMON,((Tag)segment).getTagType());
      assertEquals("<%@ page language=\"java\" %>",segment.toString());
      assertEquals(120,streamedSource.getBufferSize());
      CharBuffer charBuffer=streamedSource.getCurrentSegmentCharBuffer();
      char[] charBufferArray=charBuffer.array();
      assertEquals(120,charBufferArray.length);
      assertEquals(segment.toString(),new String(charBufferArray,charBuffer.position(),charBuffer.length()));
      segment=i.next();
      assertEquals(StartTagType.SERVER_COMMON,((Tag)segment).getTagType());
      assertEquals("<%@ taglib uri=\"/WEB-INF/struts-i18n.tld\" prefix=\"i18n\" %>",segment.toString());
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.