Package java.nio

Examples of java.nio.ByteBuffer.array()


      data.put(SEARCH_BY_LIMIT);
      data.putShort(Convert.intToShort(str.length()));
      data.put(str.getBytes());
      data.putShort(Convert.intToShort(TAG_NAME_FORMAT.length));
      data.put(TAG_NAME_FORMAT);
      return data.array();
    }
    return null;
  }

}
View Full Code Here


  }
 
  public static byte[] intToByteArray(int value) {
    ByteBuffer data = Misc.getByteBuffer(4);
    data.putInt(value);
    return data.array();
  }
 
  public static byte[] shortToByte(short value) {
    ByteBuffer data = Misc.getByteBuffer(2);
    data.putShort(value);
View Full Code Here

  }
 
  public static byte[] shortToByte(short value) {
    ByteBuffer data = Misc.getByteBuffer(2);
    data.putShort(value);
    return data.array();
  }
 
  public static short intToShort(int value){
    ByteBuffer data = Misc.getByteBuffer(4);
    data.putInt(value);
View Full Code Here

     
      ByteBuffer hashset = Misc.getByteBuffer(16);
     
      msgDigest.finalDigest(hashset);
     
      if (!Arrays.equals(hashSet.get(partID),hashset.array())) {
        return false;
      }
      return true;
     
    } catch (IOException e) {
View Full Code Here

    ByteBuffer tmp = Misc.getByteBuffer(4);

    for(int i = 0;i<16;i+=4) {
      tmp.clear();
      tmp.put(byteArray, i, 4);
      reversed.put(Convert.reverseArray(tmp.array()));
    }
   
    byteArrayToBitSet(reversed.array(), bit_set);
  }
 
View Full Code Here

  public long get32Bit(int begin) {
    byte[] byteArray = bitSetToByteArray(bit_set);
    ByteBuffer buffer = Misc.getByteBuffer(4);
    buffer.put(byteArray, begin, 4);
    buffer.position(0);
    buffer.put(Convert.reverseArray(buffer.array()));
   
    return Convert.intToLong(buffer.getInt(0));
  }

  /**
 
View Full Code Here

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

      ByteBuffer tmp = Misc.getByteBuffer(4);
 
      for(int i = 0;i<16;i+=4) {
        tmp.clear();
        tmp.put(byteArray, i, 4);
        reversed.put(Convert.reverseArray(tmp.array()));
      }
     
      return reversed.array();
    }
    return bitSetToByteArray(bit_set);
View Full Code Here

      else
        numBytes = srcs.remaining();

      int ipos = srcs.position();
      ByteBuffer toSend = Misc.getByteBuffer(numBytes);
      srcs.get(toSend.array(), 0, numBytes);
      toSend.position(0);

      int sended = channel.write(toSend);
      if (sended == -1) {
        return -1;
View Full Code Here

    List<ByteBuffer> vector = new Vector<ByteBuffer>();
   
    do {
      ByteBuffer tmpData = Misc.getByteBuffer(BLOCK_SIZE);
     
      byte_count = compressor.deflate(tmpData.array());
   
      if (byte_count == 0) break;
     
      tmpData.limit(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.