Package java.nio

Examples of java.nio.CharBuffer.flip()


                //
                cb.clear();
                bb.clear();
                cb.put(cbuf, off, charsRead);
                cb.flip();
                m_encoder.encode(cb, bb, /*endOfinput*/ true);
                bb.flip();

                bytesRead = bb.limit();

View Full Code Here


            }
            private void flush0() throws IOException {

                final CharBuffer cb = m_charBuffer;

                cb.flip();

                final char[] chars = new char[cb.length()];

                cb.get(chars);
                cb.clear();
View Full Code Here

                if (cb.remaining() == 0) {
                    cb.clear();

                    charsRead = m_reader.read(cb);

                    cb.flip();

                    if (charsRead < 0) {
                        setEOF();

                        return -1;
View Full Code Here

    // allocate enough space for "out"
    out = CharBuffer.allocate(10);
    // replace string should be put into "out" firstly,
    // and then decode "in".
    result = decoder.decode(in, out, true);
    out.flip();
    assertTrue(result.isUnderflow());
    assertEquals("bb", out.toString());
  }

  /*
 
View Full Code Here

        Writer writer = Channels.newWriter(socketChannel, "utf-8");
        CharBuffer buffer = CharBuffer.allocate(512);
        StringBuilder builder = new StringBuilder();

        while (reader.read(buffer) != -1) {
          buffer.flip();

          logger.debug("read {} characters", buffer.remaining());

          counterGroup.addAndGet("characters.received",
              Long.valueOf(buffer.limit()));
View Full Code Here

        if ( r.isOverflow() )
            throw new InternalErrorException("fromByteBuffer: decode overflow (1)") ;
        r = dec.flush(cBuff) ;
        if ( r.isOverflow() )
            throw new InternalErrorException("fromByteBuffer: decode overflow (2)") ;
        cBuff.flip();
        return cBuff.toString() ;
    }

    /** Return a hex string representing the bytes, zero padded to length of byte array. */
    public static String asHex(byte[] bytes)
View Full Code Here

    public static String encode(Readable readable, String enc, Filter... filters) throws IOException {
        StringBuilder sb = new StringBuilder();
        CharBuffer chars = CharBuffer.allocate(1024);
        while (readable.read(chars) > -1) {
            chars.flip();
            processChars(sb, chars, enc, filters);
        }
        return sb.toString();
    }
View Full Code Here

    while (true) {
      final int n = input.read(buffer);
      if (n == -1) {
        break;
      }
      buffer.flip();
      text.append(buffer, 0, n);
    }
    return text;
  }
View Full Code Here

            FileReader reader = new FileReader(config._temp);
            CharBuffer buffer = CharBuffer.allocate(256 * 1024);
            reader.read(buffer);
            reader.close();
            config._temp.delete();
            buffer.flip();

            String raw = buffer.toString();
            System.out.print(raw);
            Stats stats = new Stats(raw);
            System.out.println(stats);
View Full Code Here

    checkNotNull(from);
    checkNotNull(to);
    CharBuffer buf = CharBuffer.allocate(BUF_SIZE);
    long total = 0;
    while (from.read(buf) != -1) {
      buf.flip();
      to.append(buf);
      total += buf.remaining();
      buf.clear();
    }
    return total;
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.