Package java.nio

Examples of java.nio.ByteBuffer.reset()


          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

            ByteBuffer bb=ByteBuffer.allocate(16);
            bb.mark();

            start=System.currentTimeMillis();
            for(int i=0; i < num_msgs; i++) {
                bb.reset();
                bb.putInt(i);
                buf=(byte[])(bb.array()).clone();

                if(jg) {
                    send_msg=new Message(null, null, buf);
View Full Code Here

        // note that this does not handle the case of a default value with nested bytes
        ByteBuffer bytes = ((ByteBuffer) o);
        bytes.mark();
        byte[] data = new byte[bytes.remaining()];
        bytes.get(data);
        bytes.reset(); // put the buffer back the way we got it
        s = new String(data, "ISO-8859-1");
        char[] quoted = JsonStringEncoder.getInstance().quoteAsString(s);
        s = "\"" + new String(quoted) + "\"";
      } else {
        s = GenericData.get().toString(o);
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

    h.check(buf.compact(), buf, "compact() return value");
    h.check(buf.position(), 4, "compact()/position");
    h.check(buf.limit(), size, "compact()/limit");
    try
      {
        buf.reset();
        h.check(false, "mark: mark not invalidated");
      }
      catch(InvalidMarkException ime)
      {
        h.check(true, "mark: invalidated mark");
View Full Code Here

        ByteBuffer graph = access.read(pos - bytes, bytes);

        byte[] b = new byte[bytes - 16];
        graph.mark();
        graph.get(b);
        graph.reset();

        CRC32 checksum = new CRC32();
        checksum.update(b);
        if (crc32 != (int) checksum.getValue()) {
            log.warn("Invalid graph checksum in tar file {}", file);
View Full Code Here

        {
            ByteBuffer stream = kerberosMessageContainer.getStream();
   
            try
            {
                stream.reset();
            }
            catch ( InvalidMarkException ime )
            {
                stream.rewind();
            }
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.