Package java.nio

Examples of java.nio.ByteBuffer.flip()


                if (transferBuffer.remaining() == 0) {
                    transferBuffer.flip();
                    write(transferBuffer);

                } else {
                    transferBuffer.flip();
                    write(transferBuffer.slice());
                }

                transfered += read;
            }
View Full Code Here


                log.debug("Reading SSL data from raw InputStream");
              // #endif
              boolean forceRead = false;
             
              do {
                inputBuffer.flip();
               
                if(!inputBuffer.hasRemaining() || forceRead) {
                 
                  inputBuffer.compact();
                  int read = rawIn.read(bufferIn);
View Full Code Here

   
                  if(read==-1)
                    throw new EOFException("Unexpected EOF whilst waiting for SSL unwrap");
                
                  inputBuffer.put(bufferIn, 0, read);
                  inputBuffer.flip();
                }
   
                 res = engine.unwrap(inputBuffer, outputBuffer);
   
                 inputBuffer.compact();
View Full Code Here

      while (matcher.find())
      {
         int b = Integer.parseInt(matcher.group(1), 16);
         bytes.put((byte) b);
      }
      bytes.flip();
      try
      {
         return decoder.decode(bytes).toString();
      }
      catch (CharacterCodingException e)
View Full Code Here

 
  public static ByteBuffer generateDirectByteBuffer(int length) {
    byte[] bytes = generateByteArray(length);
    ByteBuffer buffer = ByteBuffer.allocateDirect(bytes.length);
    buffer.put(bytes);
    buffer.flip();
    return buffer;
  }
 
  public static ByteBuffer[] generateDirectByteBufferArray(int elements, int length) {
    ByteBuffer[] byteBufferArray = new ByteBuffer[elements];
View Full Code Here

       
      RandomAccessFile raf = new RandomAccessFile(file2, "r");
        FileChannel fc = raf.getChannel();
        ByteBuffer buf = ByteBuffer.allocate((int) fc.size());
        fc.read(buf);
        buf.flip();
       
        boolean isEquals = isEquals(file, new ByteBuffer[] { buf });
       
        fc.close();
        raf.close();
View Full Code Here

    RandomAccessFile raf = new RandomAccessFile(file, "r");
    FileChannel fc = raf.getChannel();
    ByteBuffer buf = ByteBuffer.allocate(length);
    fc.read(buf);
    buf.flip();
   
    boolean isEquals = isEquals(buf, buffers);
   
    fc.close();
    raf.close();
View Full Code Here

          byteBuffer.position(pos);
          byteBuffer.limit(limit);
        }
      }
     
      buffer.flip();
      return buffer;
    }
  }

 
View Full Code Here

        ByteBuffer buffer = ByteBuffer.allocate((int) fc.size());
        fc.read(buffer);
        fc.close();
        raf.close();
        buffer.flip();
       
        return new ByteBuffer[] { buffer };
    }
 
 
View Full Code Here

    ReadableByteChannel bodyChannel= response.getBody();
     
    ByteBuffer transferBuffer = ByteBuffer.allocateDirect(8192);
           
    while (bodyChannel.read(transferBuffer) != -1) {
      transferBuffer.flip();
     
      while (transferBuffer.hasRemaining()) {
        fc.write(transferBuffer);
        }
      transferBuffer.clear();
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.