Package java.nio

Examples of java.nio.ByteBuffer.flip()


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

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

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


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

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

                transfered += read;
            }
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

        ByteBuffer buffer = ByteBuffer.allocate((int) fc.size());
        fc.read(buffer);
        fc.close();
        raf.close();
        buffer.flip();
       
        // add part
        addPart(DataConverter.toByteBuffer(header), buffer);
  }
   
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 buffer = ByteBuffer.allocate((int) fc.size());
        fc.read(buffer);
        fc.close();
        raf.close();
        buffer.flip();
       
        // add part
        addPart(DataConverter.toByteBuffer(header), buffer);
  }
   
View Full Code Here

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

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

                } else {
                    transferBuffer.flip();
                    write(transferBuffer.slice());
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.