Package java.nio

Examples of java.nio.ByteBuffer.reset()


              src.reset();
              found = false;
              break;
            }
            if (!(tgt.get() == src.get())) {
              tgt.reset();
              src.reset();
              found = false;
              break; // no match
            }
          }
View Full Code Here


  private static ByteBuffer directify(ByteBuffer dataBuf) {
    ByteBuffer newBuf = ByteBuffer.allocateDirect(dataBuf.capacity());
    newBuf.position(dataBuf.position());
    newBuf.mark();
    newBuf.put(dataBuf);
    newBuf.reset();
    newBuf.limit(dataBuf.limit());
    return newBuf;
  }
}
View Full Code Here

                                encode.mark();
                                int c1 = safeGet(encode);
                                if (c1 == '\n' || (c1 == '\r' && (c1 = safeGet(encode)) == '\n')) continue;
                                int d1 = Character.digit(c1, 16);
                                if (d1 == -1) {
                                    encode.reset();
                                    break;
                                }
                                encode.mark();
                                if (!encode.hasRemaining()) break;
                                int c2 = safeGet(encode);
View Full Code Here

                                encode.mark();
                                if (!encode.hasRemaining()) break;
                                int c2 = safeGet(encode);
                                int d2 = Character.digit(c2, 16);
                                if (d2 == -1) {
                                    encode.reset();
                                    break;
                                }
                                byte value = (byte)(d1 << 4 | d2);
                                lElem[index++] = value;
                            }
View Full Code Here

    } else {
      // Slow path, if the byte buffer doesn't have array
      byte[] bytes = new byte[body.remaining()];
      body.mark();
      body.get(bytes);
      body.reset();
      out.value(Bytes.toStringBinary(bytes));
    }
    out.endObject();
  }
View Full Code Here

        }

        ByteBuffer dstbuf = dst.buffer;
        dstbuf.mark();
        src.getBytes(src.readerIndex(), dstbuf);
        dstbuf.reset();
        return dst;
    }

    private Preallocation getPreallocation() {
        Preallocation current = this.current;
View Full Code Here

    // using that encoder.
    //
    try {
      return decode(b, Constants.CHARSET);
    } catch (CharacterCodingException e) {
      b.reset();
    }

    if (!cs.equals(Constants.CHARSET)) {
      // Try the suggested encoding, it might be right since it was
      // provided by the caller.
View Full Code Here

      // provided by the caller.
      //
      try {
        return decode(b, cs);
      } catch (CharacterCodingException e) {
        b.reset();
      }
    }

    // Try the default character set. A small group of people
    // might actually use the same (or very similar) locale.
View Full Code Here

    final Charset defcs = Charset.defaultCharset();
    if (!defcs.equals(cs) && !defcs.equals(Constants.CHARSET)) {
      try {
        return decode(b, defcs);
      } catch (CharacterCodingException e) {
        b.reset();
      }
    }

    throw new CharacterCodingException();
  }
View Full Code Here

                if ( remaining > nbStored )
                {
                    pageData.mark();
                    pageData.position( pagePos );
                    pageData.put( bytes, bytes.length - nbStored, nbStored );
                    pageData.reset();
                    nbStored = 0;
                }
                else
                {
                    pageData.mark();
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.