Package java.nio

Examples of java.nio.CharBuffer.array()


        // we will abort parsing when 1 Mega of queued chars was found.
        if (buffer.length() > maxBufferSize) {
            throw new Exception("Stopped parsing never ending stanza");
        }
        CharBuffer charBuffer = encoder.decode(byteBuffer.buf());
        char[] buf = charBuffer.array();
        int readByte = charBuffer.remaining();

        // Just return if nothing was read
        if (readByte == 0) {
            return;
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

    ByteBuffer bb = ByteBuffer.allocate (bytes.length);
    bb.put (bytes);
                bb.flip ();
    CharBuffer cb = cs.decode (bb);
   
    return cb.array();
  }

}
View Full Code Here

    // we will abort parsing when 1 Mega of queued chars was found.
    if (buffer.length() > maxBufferSize) {
      throw new Exception("Stopped parsing never ending stanza");
    }
    CharBuffer charBuffer = encoder.decode(byteBuffer.buf());
    char[] buf = charBuffer.array();
    int readByte = charBuffer.remaining();

    // Just return if nothing was read
    if (readByte == 0) {
      return;
View Full Code Here

    ByteBuffer bb = ByteBuffer.allocate (bytes.length);
    bb.put (bytes);
                bb.flip ();
    CharBuffer cb = cs.decode (bb);
   
    return cb.array();
  }

}
View Full Code Here

        if (charContent == null)
            throw new UnsupportedOperationException();
        if (charContent instanceof CharBuffer) {
            CharBuffer buffer = (CharBuffer)charContent;
            if (buffer.hasArray())
                return new CharArrayReader(buffer.array());
        }
        return new StringReader(charContent.toString());
    }

    /**
 
View Full Code Here

    ByteBuffer bb = ByteBuffer.allocate (bytes.length);
    bb.put (bytes);
                bb.flip ();
    CharBuffer cb = cs.decode (bb);
   
    return cb.array();
  }

}
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

        // 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

        if (socketIO.bytesRead() > 0) {
          empty_read_call_count = 0;
          tmpBuffer.flip();
          cb = decoder.decode(tmpBuffer);
          tmpBuffer.clear();
          addRead(cb.array().length);
        } else {
          // Detecting infinite read 0 bytes
          // sometimes it happens that the connection has been lost
          // and the select thinks there are some bytes waiting for reading
          // and 0 bytes are read
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.