Package java.nio

Examples of java.nio.ByteBuffer.limit()


  public final ByteBuffer getRecordHeaderBuffer() throws IOException {
    final ByteBuffer b = this.getRecordByteBuffer();
    final int start = offset;
    final int length = this.getRecordHeaderLength();

    b.limit(start + length);
    b.position(start);

    return b;
  }
View Full Code Here


   * @return
   * @throws IOException
   */
  public long getRecordLength() throws IOException {
    final ByteBuffer b = getRecordByteBuffer();
    final int length = b.limit() - b.position();

    return length;
  }

  /**
 
View Full Code Here

        publisher.processNoteResponse(new Int128(noteID), load);
      } else if (packetOPCode == KADEMLIA_SEARCH_REQ) {
        byte targetID[] = new byte[16];
        rawData.get(targetID);
        boolean sourceSearch = false;
        if (rawData.limit() == 17)
          if (rawData.get() == 1)
            sourceSearch = true;
        List<Source> source_list;

        if (sourceSearch)
View Full Code Here

      List<ByteBuffer> shared_files_data = new LinkedList<ByteBuffer>();
      for(SharedFile sFile : sharedFiles) {
        TagList tag_list = sFile.getTagList();
        int tag_list_size = tag_list.getByteSize();
        ByteBuffer buffer = Misc.getByteBuffer(16 + 4 + 2 + 4 + tag_list_size);
        data_length += buffer.limit();
        buffer.position(0);
        buffer.put(sFile.getFileHash().getHash());
        if (userID.isHighID()) {
          buffer.put(userID.getClientID());
          buffer.putShort((short)ConfigurationManagerSingleton.getInstance().getTCP());
View Full Code Here

    try {
     
      readChannel.position(start);
     
      int count = readChannel.read(partData);
      partData.limit(count);
      msgDigest.update(partData);
     
      ByteBuffer hashset = Misc.getByteBuffer(16);
     
      msgDigest.finalDigest(hashset);
View Full Code Here

    packetBuffer.position(0);
    do {
      int mustRead = downloadController.getAvailableByteCount(packetBuffer
          .remaining(), true);
      readCache.position(0);
      readCache.limit(mustRead);

      read(readCache, mustRead);
      int readedData = readCache.limit();
      totalReaded += readedData;
      downloadController.markBytesUsed(readedData);
View Full Code Here

          .remaining(), true);
      readCache.position(0);
      readCache.limit(mustRead);

      read(readCache, mustRead);
      int readedData = readCache.limit();
      totalReaded += readedData;
      downloadController.markBytesUsed(readedData);
      packetBuffer.put(readCache.array(), 0, readedData);
    } while (packetBuffer.hasRemaining());
    transferred_bytes += totalReaded;
View Full Code Here

  private int read(ByteBuffer packetBuffer, int bytes) throws IOException,
      JMEndOfStreamException {
    ByteBuffer readCache = Misc.getByteBuffer(bytes);
    int mustRead = bytes;
    do {
      readCache.limit(mustRead);
      readCache.position(0);
      int readedData = 0;

      readedData = channel.read(readCache); // return -1 if socket is
                          // closed
View Full Code Here

      if (readedData == -1) {
        throw new JMEndOfStreamException();
      }

      mustRead -= readedData;
      readCache.limit(readedData);
      readCache.position(0);
      packetBuffer.put(readCache);
    } while (mustRead > 0);
    transferred_bytes += bytes;
    return bytes;
View Full Code Here

     
      byte_count = compressor.deflate(tmpData.array());
   
      if (byte_count == 0) break;
     
      tmpData.limit(byte_count);
     
      vector.add(tmpData);
     
      capacity += byte_count;
     
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.