Examples of averageCharsPerByte()


Examples of java.nio.charset.CharsetDecoder.averageCharsPerByte()

            return (CharBuffer)CharBuffer.allocate(1).flip();
        }

        // slightly overestimate the buffer size to avoid reallocation.
        float factor =
            decoder.averageCharsPerByte() * 0.8f +
            decoder.maxCharsPerByte() * 0.2f;
        CharBuffer dest = CharBuffer.
            allocate(10 + (int)(inbuf.remaining()*factor));

        while (true) {
View Full Code Here

Examples of java.nio.charset.CharsetDecoder.averageCharsPerByte()

   
    ByteBuffer utf8buf = staticBuffers.byteBuffer(UTF8_BUFFER, 1024 * 8);
    byte[] rawUtf8Buf = utf8buf.array();

    CharsetDecoder dec = Charset.forName("UTF-8").newDecoder();
    int expectedLen = (len > 0 ? (int)(dec.averageCharsPerByte() * len) + 1 : 1024);
    CharBuffer cb = staticBuffers.charBuffer(UTF8_BUFFER, expectedLen);
    try {
      while (len != 0 || utf8buf.position() > 0) {
        //read as much as possible
        if (len < 0) {
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.