Package java.nio

Examples of java.nio.ByteBuffer.mark()


                    {
                        LOG.debug( Strings.dumpBytes(array) );
                    }
                }

                buf.mark();

                if ( messageContainer.getState() == TLVStateEnum.PDU_DECODED )
                {
                    if ( IS_DEBUG )
                    {
View Full Code Here


                    Message message = ( ( LdapMessageContainer<?> ) ldapMessageContainer ).getMessage();

                    if ( IS_DEBUG )
                    {
                        LOG.debug( "Decoded LdapMessage : " + message );
                        buf.mark();
                    }

                    // Clean the container for the next decoding
                    ( ( LdapMessageContainer<?> ) ldapMessageContainer ).clean();
View Full Code Here

      src.position(start);
         
      while (src.hasRemaining()) {
        if (b == src.get()) { // matching first byte
          src.mark(); // save position in loop
          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();
View Full Code Here

            receiver=new Receiver(sock, channel, matrix, jg);
            receiver.start();

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

            start=System.currentTimeMillis();
            for(int i=0; i < num_msgs; i++) {
                bb.reset();
                bb.putInt(i);
View Full Code Here

            Message msg;
            byte[] msg_data=null;
            long total_time;
            double msgs_per_sec=0;
            ByteBuffer rb=ByteBuffer.allocate(16);
            rb.mark();

            packet=new DatagramPacket(buf, buf.length);
            while(num_received <= num_msgs) {
                try {
                    if(jg) {
View Full Code Here

                   
                    if ( IS_DEBUG )
                    {
                        LOG.debug( "Decoded LdapMessage : " +
                                ( ( LdapMessageContainer ) ldapMessageContainer ).getLdapMessage() );
                        buf.mark();
                    }
   
                    // Clean the container for the next decoding
                    ( ( LdapMessageContainer ) ldapMessageContainer).clean();
                   
View Full Code Here

      String s;
      if (o instanceof ByteBuffer) {
        // special case since GenericData.toString() is incorrect for bytes
        // 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);
View Full Code Here

   */
  public static String decodeNoFallback(final Charset cs,
      final byte[] buffer, final int start, final int end)
      throws CharacterCodingException {
    final ByteBuffer b = ByteBuffer.wrap(buffer, start, end - start);
    b.mark();

    // Try our built-in favorite. The assumption here is that
    // decoding will fail if the data is not actually encoded
    // using that encoder.
    //
View Full Code Here

    {
      buf.put((byte)(i + 1));
    }
    buf.limit(6);
    buf.position(1);
    buf.mark();
    buf.get();
   
    h.check(buf.compact(), buf, "compact() return value");
    h.check(buf.position(), 4, "compact()/position");
    h.check(buf.limit(), size, "compact()/limit");
View Full Code Here

        // this involves seeking backwards in the file, which might not
        // perform well, but that's OK since we only do this once per file
        ByteBuffer index = ByteBuffer.allocate(count * 24);
        file.seek(length - 2 * BLOCK_SIZE - 16 - count * 24);
        file.readFully(index.array());
        index.mark();

        CRC32 checksum = new CRC32();
        long limit = length - 2 * BLOCK_SIZE - bytes - BLOCK_SIZE;
        long lastmsb = Long.MIN_VALUE;
        long lastlsb = Long.MIN_VALUE;
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.