Package java.nio

Examples of java.nio.ByteBuffer.reset()


      try {
        type = buffer.getShort();
        length  = buffer.getShort();
      } catch (BufferUnderflowException e) {
        buffer.reset();
        throw new InvalidLogBufferException();
      }
      if (buffer.position() + length > lb.bytesUsed) {
        buffer.reset();
        throw new InvalidLogBufferException();
View Full Code Here


      } catch (BufferUnderflowException e) {
        buffer.reset();
        throw new InvalidLogBufferException();
      }
      if (buffer.position() + length > lb.bytesUsed) {
        buffer.reset();
        throw new InvalidLogBufferException();
      }
     
      if (length > data.length) {
        // reallocate buffer to accomodate record
View Full Code Here

          tgt.mark(); // save position in target
          boolean found = true;
          int pos = src.position() - 1;
          while (tgt.hasRemaining()) {
            if (!src.hasRemaining()) { // src expired first
              tgt.reset();
              src.reset();
              found = false;
              break;
            }
            if (!(tgt.get() == src.get())) {
View Full Code Here

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

                message = pendingWrites.remove();
                isWriting = false;
            }
            if (logger.isLoggable(Level.FINEST)) {
    ByteBuffer resetMessage = message.duplicate();
    resetMessage.reset();
                logger.log(Level.FINEST,
         "completed write protocol:{0} message:{1}",
         SimpleSgsProtocolImpl.this,
         HexDumper.format(resetMessage, 0x50));
            }
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

        assert buffer != null;
        ByteBuffer cloned = allocate(buffer.remaining());

        cloned.mark();
        cloned.put(buffer.duplicate());
        cloned.reset();
        return cloned;
    }

    public abstract ByteBuffer allocate(int size);
}
View Full Code Here

          tgt.mark(); // save position in target
          boolean found = true;
          int pos = src.position()-1;
          while (tgt.hasRemaining()) {
            if (!src.hasRemaining()) { // src expired first
              tgt.reset();
              src.reset();
              found = false;
              break;
            }
            if (!(tgt.get() == src.get())) {
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.