Package java.nio

Examples of java.nio.ByteBuffer.flip()


      handshake.put( (byte)5 ); // socks 5
      handshake.put( (byte)2 ); // 2 methods
      handshake.put( (byte)0 ); // no auth
      handshake.put( (byte)2 ); // user/pw

      handshake.flip();
      socks5_handshake_phase = 1;

      return new ByteBuffer[] { handshake, ByteBuffer.allocate( 2 ) };   //TODO convert to direct?
    }
   
View Full Code Here


      handshake.put( (byte)socks_user.length() ); // user length
      handshake.put( socks_user.getBytes() );
      handshake.put( (byte)socks_password.length() ); // password length
      handshake.put( socks_password.getBytes() );

      handshake.flip();
      socks5_handshake_phase = 2;

      return new ByteBuffer[] { handshake, ByteBuffer.allocate( 2 ) };   //TODO convert to direct?
    }
   
View Full Code Here

        handshake.put( mapped_ip.getBytes() );
      }

      handshake.putShort( (short)remote_address.getPort() ); // port
     
      handshake.flip();
      socks5_handshake_phase = 3;

      return new ByteBuffer[] { handshake, ByteBuffer.allocate( 5 ) };   //TODO convert to direct?
    }
   
View Full Code Here

       
        //  test the XML file by displaying the first 1024 characters
      FileChannel fc = fisXML.getChannel();
      ByteBuffer buf = ByteBuffer.allocate((int)fc.size());
      fc.read(buf);
      buf.flip();
  //      while(buf.hasRemaining())
  //        System.out.print((char)buf.get());
  //      fisXML.close();
  //      System.out.print('\n');
 
View Full Code Here

   */
  public static ByteOrder checkFormat(ReadableByteChannel in)
      throws IOException {
    ByteBuffer b = ByteBuffer.allocate(4);
    in.read(b);
    b.flip();

    if (PcapFile.headerReader.readType(b) != RecordType.BlockRecord) {
      return null;
    }

View Full Code Here

      if(i%2==0){
        System.out.println("write "+m.write(in,0,in.length-(i%3)));
      }
      else{
        bin.put(in,0,in.length-(i%3));
        bin.flip();
        System.out.println("write buffer"+m.write(bin));
        bin.clear();
      }
      for(int j=0;j<in.length;j++){
        in[j]++;
View Full Code Here

      }

      if (bucketChanged) {
        // Some of the items were moved to the new bucket, write it to the
        // file
        newBucket.flip();
        fileChannel.write(newBucket, newBucketOffset);
        newBucket.clear();
      }

      // Reset overflow ID in the old bucket to 0 if necessary
View Full Code Here

      ByteBuffer transferBuffer = ByteBuffer.allocate(chunkSize);
      read = bodyDatasource.read(transferBuffer);

      if (read > 0) {
        if (transferBuffer.remaining() == 0) {
          transferBuffer.flip();
          buffers.add(transferBuffer);

        } else {
          transferBuffer.flip();
          buffers.add(transferBuffer.slice());
View Full Code Here

        if (transferBuffer.remaining() == 0) {
          transferBuffer.flip();
          buffers.add(transferBuffer);

        } else {
          transferBuffer.flip();
          buffers.add(transferBuffer.slice());
        }
      }
    } while (read > 0);
   
View Full Code Here

    ByteBuffer buffer = ByteBuffer.allocate(getContentLength());
    fc.read(buffer);
    fc.close();
    raf.close();
    buffer.flip();
   
    getNonBlockingBody().append(true, buffer);
    getNonBlockingBody().setComplete(true);
  }
 
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.