Package java.nio

Examples of java.nio.CharBuffer.arrayOffset()


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


                        charBuffer = decoder.decode(buf);
                    } catch (CharacterCodingException e) {
                        throw Utils.asRuntime(e);
                    }
                    buf.limit(buf.capacity());
                    String s = new String(charBuffer.array(), charBuffer.arrayOffset(), charBuffer.limit());
                    buf.position(0);
                    return s;
                } else {
                    return "";
                }
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());
    }

    /**
     * @deprecated Unused. Will be removed in Tomcat 8.0.x onwards.
     */
 
View Full Code Here

        ((StringBuilder) csq).getChars(start, end, termBuffer, termLength);
      } else if (csq instanceof CharTermAttribute) {
        System.arraycopy(((CharTermAttribute) csq).buffer(), start, termBuffer, termLength, len);
      } else if (csq instanceof CharBuffer && ((CharBuffer) csq).hasArray()) {
        final CharBuffer cb = (CharBuffer) csq;
        System.arraycopy(cb.array(), cb.arrayOffset() + cb.position() + start, termBuffer, termLength, len);
      } else if (csq instanceof StringBuffer) {
        ((StringBuffer) csq).getChars(start, end, termBuffer, termLength);
      } else {
        while (start < end)
          termBuffer[termLength++] = csq.charAt(start++);
View Full Code Here

            CharBuffer buf = (CharBuffer) string;
            if (buf.hasArray()) {
                return copiedBuffer(
                        endianness,
                        buf.array(),
                        buf.arrayOffset() + buf.position() + offset,
                        length, charset);
            }

            buf = buf.slice();
            buf.limit(length);
View Full Code Here

                        charBuffer = decoder.decode(buf);
                    } catch (CharacterCodingException e) {
                        throw Utils.asRuntime(e);
                    }
                    buf.limit(buf.capacity());
                    String s = new String(charBuffer.array(), charBuffer.arrayOffset(), charBuffer.limit());
                    buf.position(0);
                    return s;
                } else {
                    return "";
                }
View Full Code Here

        try {
            chars = decoder.decode(wrap);
        } catch (CharacterCodingException e) {
            throw asRuntime(e);
        }
        return new String(chars.array(), chars.arrayOffset(), chars.limit());
    }

    /**
     * Insert an element as the first to an array. The input array is
     * not changed, instead a copy is returned.
View Full Code Here

        try {
            chars = decoder.decode(wrap);
        } catch (CharacterCodingException e) {
            throw asRuntime(e);
        }
        return new String(chars.array(), chars.arrayOffset(), chars.limit());
    }

    /**
     * Insert an element as the first to an array. The input array is
     * not changed, instead a copy is returned.
View Full Code Here

        if (string instanceof CharBuffer) {
            CharBuffer buf = (CharBuffer) string;
            if (buf.hasArray()) {
                return copiedBuffer(
                        buf.array(),
                        buf.arrayOffset() + buf.position() + offset,
                        length, charset);
            }

            buf = buf.slice();
            buf.limit(length);
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());
    }

    /**
     * @deprecated Unused. Will be removed in Tomcat 8.0.x onwards.
     */
 
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.