Package java.nio

Examples of java.nio.CharBuffer.arrayOffset()


            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


        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

            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

    }

    private String textFromBytes(byte[] bytes) throws CharacterCodingException {
        ByteBuffer wrap = ByteBuffer.wrap(bytes);
        CharBuffer chars = this.textDecoder.decode(wrap);
        return new String(chars.array(), chars.arrayOffset(), chars.limit());
    }

}
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

        }
        // 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 = charset.decode(ByteBuffer.wrap(buff, start, end-start));
        return new String(cb.array(), cb.arrayOffset(), cb.length());
    }

    public long getLong() {
        return Ascii.parseLong(buff, start,end-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

      return ((CharSequenceBackedByArray)seq).getChars();
    }

    if (seq instanceof CharBuffer) {
      final CharBuffer buffer = (CharBuffer)seq;
      if (buffer.hasArray() && !buffer.isReadOnly() && buffer.arrayOffset() == 0) {
        return buffer.array();
      }
    }

    return null;
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.