Package java.nio

Examples of java.nio.CharBuffer.remaining()


            }
            if (cr.isOverflow()) {
                if (isAutoExpand()) {
                    switch (expandedState) {
                    case 0:
                        autoExpand((int) Math.ceil(in.remaining()
                                * encoder.averageBytesPerChar()));
                        expandedState++;
                        break;
                    case 1:
                        autoExpand((int) Math.ceil(in.remaining()
View Full Code Here


                        autoExpand((int) Math.ceil(in.remaining()
                                * encoder.averageBytesPerChar()));
                        expandedState++;
                        break;
                    case 1:
                        autoExpand((int) Math.ceil(in.remaining()
                                * encoder.maxBytesPerChar()));
                        expandedState++;
                        break;
                    default:
                        throw new RuntimeException("Expanded by "
View Full Code Here

                                * encoder.maxBytesPerChar()));
                        expandedState++;
                        break;
                    default:
                        throw new RuntimeException("Expanded by "
                                + (int) Math.ceil(in.remaining()
                                        * encoder.maxBytesPerChar())
                                + " but that wasn't enough for '" + val + "'");
                    }
                    continue;
                }
View Full Code Here

            return (Reader)transferObject;
        } else if (transferObject instanceof String) {
            return new StringReader((String)transferObject);
        } else if (transferObject instanceof CharBuffer) {
            CharBuffer buffer = (CharBuffer)transferObject;
            int size = buffer.remaining();
            char[] chars = new char[size];
            buffer.get(chars, 0, size);
            return new CharArrayReader(chars);
        } else if (transferObject instanceof char[]) {
            return new CharArrayReader((char[])transferObject);
View Full Code Here

        if (transferObject instanceof InputStream) {
            stream = (InputStream)transferObject;
        } else if (transferObject instanceof ByteBuffer) {
            ByteBuffer buffer = (ByteBuffer)transferObject;
            int size = buffer.remaining();
            byte[] bytes = new byte[size];
            buffer.get(bytes, 0, size);
            stream = new ByteArrayInputStream(bytes);
        } else if (transferObject instanceof byte[]) {
            stream = new ByteArrayInputStream((byte[])transferObject);
View Full Code Here

    public ByteBuffer encode(CharSequence sequence) {
        CharBuffer buffer = CharBuffer.wrap(sequence);
        CharsetEncoder encoder = getEncoder();

        int n = 0;
        if (buffer.remaining() > 0) {
            n = (int) (buffer.remaining() * encoder.averageBytesPerChar());
            if (n == 0) {
                n = (int) (buffer.remaining() * encoder.maxBytesPerChar());
            }
        }
View Full Code Here

        CharBuffer buffer = CharBuffer.wrap(sequence);
        CharsetEncoder encoder = getEncoder();

        int n = 0;
        if (buffer.remaining() > 0) {
            n = (int) (buffer.remaining() * encoder.averageBytesPerChar());
            if (n == 0) {
                n = (int) (buffer.remaining() * encoder.maxBytesPerChar());
            }
        }
        ByteBuffer result = ByteBuffer.allocate(n); // judge result length
View Full Code Here

        int n = 0;
        if (buffer.remaining() > 0) {
            n = (int) (buffer.remaining() * encoder.averageBytesPerChar());
            if (n == 0) {
                n = (int) (buffer.remaining() * encoder.maxBytesPerChar());
            }
        }
        ByteBuffer result = ByteBuffer.allocate(n); // judge result length
        if (n == 0) {
            return result;
View Full Code Here

        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

    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

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.