當前位置: 首頁>>代碼示例>>Java>>正文


Java ByteBuffer.putLong方法代碼示例

本文整理匯總了Java中java.nio.ByteBuffer.putLong方法的典型用法代碼示例。如果您正苦於以下問題:Java ByteBuffer.putLong方法的具體用法?Java ByteBuffer.putLong怎麽用?Java ByteBuffer.putLong使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.nio.ByteBuffer的用法示例。


在下文中一共展示了ByteBuffer.putLong方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getPartialBytes

import java.nio.ByteBuffer; //導入方法依賴的package包/類
private ByteBuffer getPartialBytes() {
	ByteBuffer bytes = ByteBuffer.allocate(ADDITIONAL_SECTION_SIZE);
       bytes.order(ByteOrder.LITTLE_ENDIAN);
       bytes.put(mediaType.value);
       bytes.put(unknown);
       bytes.putInt(chunkCount);
       bytes.putInt(sectorsPerChunk);
       bytes.putInt(bytesPerSector);
       bytes.putLong(sectorCount);
       bytes.putInt(cylinders);
       bytes.putInt(heads);
       bytes.putInt(sectors);
       bytes.putInt(mediaFlag);
       bytes.putInt(palmVolumeStartSector);
       bytes.put(unknown2);
       bytes.putInt(smartLogStartSector);
       bytes.putInt(compressionLevel);
       bytes.putInt(errorGranularity);
       bytes.put(unknown3);
       bytes.put(fileSetGUID);
       bytes.put(unknown4);
       bytes.put(signature);
	return bytes;
}
 
開發者ID:ciphertechsolutions,項目名稱:IO,代碼行數:25,代碼來源:VolumeSection.java

示例2: processRequest

import java.nio.ByteBuffer; //導入方法依賴的package包/類
@Override
JSONStreamAware processRequest(HttpServletRequest req) {
	JSONObject response = new JSONObject();
	
	response.put("height", Long.toString(Nxt.getBlockchain().getHeight() + 1));
	
	Block lastBlock = Nxt.getBlockchain().getLastBlock();
	byte[] lastGenSig = lastBlock.getGenerationSignature();
	Long lastGenerator = lastBlock.getGeneratorId();
	
	ByteBuffer buf = ByteBuffer.allocate(32 + 8);
	buf.put(lastGenSig);
	buf.putLong(lastGenerator);
	
	Shabal256 md = new Shabal256();
	md.update(buf.array());
	byte[] newGenSig = md.digest();
	
	response.put("generationSignature", Convert.toHexString(newGenSig));
	response.put("baseTarget", Long.toString(lastBlock.getBaseTarget()));
	
	return response;
}
 
開發者ID:muhatzg,項目名稱:burstcoin,代碼行數:24,代碼來源:GetMiningInfo.java

示例3: alignedWriteSnippet

import java.nio.ByteBuffer; //導入方法依賴的package包/類
byte[] alignedWriteSnippet(byte a, byte b, short c, int d, long e, double f, float g) {
    byte[] ret = new byte[28];
    ByteBuffer buffer = makeDirect(28, byteOrder);

    buffer.put(a);
    buffer.put(b);
    buffer.putShort(c);
    buffer.putInt(d);
    buffer.putLong(e);
    buffer.putDouble(f);
    buffer.putFloat(g);

    buffer.position(0);
    buffer.get(ret);

    return ret;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:18,代碼來源:DirectByteBufferTest.java

示例4: toBase64

import java.nio.ByteBuffer; //導入方法依賴的package包/類
/**
 * Turns a UUID in string format to a Base64 encoded version
 *
 * @param uuidString String representation of the uuid
 * @return base64 encoded version of the uuid
 * @throws IllegalArgumentException String must be a valid uuid
 * @throws NullPointerException     String cannot be null
 */
public static String toBase64(final String uuidString) {
    if (uuidString == null) throw new NullPointerException("String cannot be null");
    if (!isUUID(uuidString)) throw new IllegalArgumentException("string must be a valid uuid");

    final UUID uuid = UUID.fromString(uuidString);
    final ByteBuffer bb = ByteBuffer.wrap(new byte[16]);
    bb.putLong(uuid.getMostSignificantBits());
    bb.putLong(uuid.getLeastSignificantBits());
    return Base64.encodeBase64URLSafeString(bb.array());
}
 
開發者ID:mhaddon,項目名稱:Sound.je,代碼行數:19,代碼來源:UUIDConverter.java

示例5: generateApkSigningBlock

import java.nio.ByteBuffer; //導入方法依賴的package包/類
private static byte[] generateApkSigningBlock(byte[] apkSignatureSchemeV2Block) {
    // FORMAT:
    // uint64:  size (excluding this field)
    // repeated ID-value pairs:
    //     uint64:           size (excluding this field)
    //     uint32:           ID
    //     (size - 4) bytes: value
    // uint64:  size (same as the one above)
    // uint128: magic

    int resultSize =
            8 // size
            + 8 + 4 + apkSignatureSchemeV2Block.length // v2Block as ID-value pair
            + 8 // size
            + 16 // magic
            ;
    ByteBuffer result = ByteBuffer.allocate(resultSize);
    result.order(ByteOrder.LITTLE_ENDIAN);
    long blockSizeFieldValue = resultSize - 8;
    result.putLong(blockSizeFieldValue);

    long pairSizeFieldValue = 4 + apkSignatureSchemeV2Block.length;
    result.putLong(pairSizeFieldValue);
    result.putInt(APK_SIGNATURE_SCHEME_V2_BLOCK_ID);
    result.put(apkSignatureSchemeV2Block);

    result.putLong(blockSizeFieldValue);
    result.put(APK_SIGNING_BLOCK_MAGIC);

    return result.array();
}
 
開發者ID:Meituan-Dianping,項目名稱:walle,代碼行數:32,代碼來源:V2SchemeSigner.java

示例6: getByteArray

import java.nio.ByteBuffer; //導入方法依賴的package包/類
public static byte[] getByteArray( long l ){
	ByteBuffer buffer = ByteBuffer.allocate(8);
	buffer.order(ByteOrder.LITTLE_ENDIAN);
	buffer.clear();
	buffer.putLong( l );
	return buffer.array();
}
 
開發者ID:muhatzg,項目名稱:burstcoin,代碼行數:8,代碼來源:AT_API_Helper.java

示例7: putMyBytes

import java.nio.ByteBuffer; //導入方法依賴的package包/類
@Override
void putMyBytes(ByteBuffer buffer) {
    buffer.putLong(purchaseId);
    buffer.putInt(goodsIsText ? goods.getData().length | Integer.MIN_VALUE : goods.getData().length);
    buffer.put(goods.getData());
    buffer.put(goods.getNonce());
    buffer.putLong(discountNQT);
}
 
開發者ID:muhatzg,項目名稱:burstcoin,代碼行數:9,代碼來源:Attachment.java

示例8: doEncodeLength

import java.nio.ByteBuffer; //導入方法依賴的package包/類
private static void doEncodeLength(ByteBuffer buf, int length) {
    if (length < 126) {
        return;
    } else if (length < 65535) {
        // FIXME? unsigned short
        buf.putShort((short) length);
    } else {
        // Unsigned long (should never have a message that large! really!)
        buf.putLong((long) length);
    }
}
 
開發者ID:Datatellit,項目名稱:xlight_android_native,代碼行數:12,代碼來源:WsFrameEncodingSupport.java

示例9: writeElementAtOffset

import java.nio.ByteBuffer; //導入方法依賴的package包/類
private void writeElementAtOffset(ByteBuffer ctx, int offset, CounterId id, long clock, long count)
{
    ctx = ctx.duplicate();
    ctx.position(offset);
    ctx.put(id.bytes().duplicate());
    ctx.putLong(clock);
    ctx.putLong(count);
}
 
開發者ID:Netflix,項目名稱:sstable-adaptor,代碼行數:9,代碼來源:CounterContext.java

示例10: gen0x11Message

import java.nio.ByteBuffer; //導入方法依賴的package包/類
private void gen0x11Message(ClientMessage cm, ArrayList<ServerMessage> smList) throws Exception{
	if(message0x11 == 0){
		return;
	}
	byte[] data = new byte[Constant.SERVER_MESSAGE_MIN_LENGTH+8];//13 bytes
	ByteBuffer bb = ByteBuffer.wrap(data);
	bb.put((byte)1);//version
	bb.put(cm.getData()[1]);//app id
	bb.put((byte)ClientStatMachine.CMD_0x11);//cmd
	bb.putShort((short)8);//length 8
	bb.putLong(message0x11);
	bb.flip();
	ServerMessage sm = new ServerMessage(cm.getSocketAddress(), data);
	smList.add(sm);
}
 
開發者ID:ahhblss,項目名稱:ddpush,代碼行數:16,代碼來源:ClientStatMachine.java

示例11: createMessageId

import java.nio.ByteBuffer; //導入方法依賴的package包/類
public static String createMessageId(final ByteBuffer input, final ByteBuffer addr, final long offset) {
    input.flip();
    input.limit(MessageDecoder.MSG_ID_LENGTH);

    input.put(addr);
    input.putLong(offset);

    return UtilAll.bytes2string(input.array());
}
 
開發者ID:y123456yz,項目名稱:reading-and-annotate-rocketmq-3.4.6,代碼行數:10,代碼來源:MessageDecoder.java

示例12: fromLane

import java.nio.ByteBuffer; //導入方法依賴的package包/類
/**
 * Converts a lane value into a byte array.
 *
 * @param data lane value to convert
 * @return converted byte array
 */

private byte[] fromLane(long data) {
    ByteBuffer buffer = ByteBuffer.allocate(8);
    buffer.putLong(data);
    buffer.clear();
    byte[] output = new byte[buffer.remaining()];
    buffer.get(output, 0, output.length);
    Collections.reverse(Bytes.asList(output));
    return output;
}
 
開發者ID:creativechain,項目名稱:creacoinj,代碼行數:17,代碼來源:Keccak.java

示例13: toInetAddress

import java.nio.ByteBuffer; //導入方法依賴的package包/類
protected static final InetAddress toInetAddress(long number) {
	ByteBuffer b8 = ByteBuffer.allocate(8);
	b8.putLong(number);
	try {
		byte[] ipv4 = new byte[4];
		System.arraycopy(b8.array(), 0, ipv4, 0, 4);
		return InetAddress.getByAddress(ipv4);
	} catch (UnknownHostException e) {
		throw new IllegalArgumentException("Unable to convert \"" + number + "\" to InetAddress!");
	}
}
 
開發者ID:berkesa,項目名稱:datatree,代碼行數:12,代碼來源:AbstractConverterSet.java

示例14: writeHeader

import java.nio.ByteBuffer; //導入方法依賴的package包/類
static void writeHeader(ByteBuffer buffer,
                        long baseOffset,
                        int lastOffsetDelta,
                        int sizeInBytes,
                        byte magic,
                        CompressionType compressionType,
                        TimestampType timestampType,
                        long baseTimestamp,
                        long maxTimestamp,
                        long producerId,
                        short epoch,
                        int sequence,
                        boolean isTransactional,
                        boolean isControlBatch,
                        int partitionLeaderEpoch,
                        int numRecords) {
    if (magic < RecordBatch.CURRENT_MAGIC_VALUE)
        throw new IllegalArgumentException("Invalid magic value " + magic);
    if (baseTimestamp < 0 && baseTimestamp != NO_TIMESTAMP)
        throw new IllegalArgumentException("Invalid message timestamp " + baseTimestamp);

    short attributes = computeAttributes(compressionType, timestampType, isTransactional, isControlBatch);

    int position = buffer.position();
    buffer.putLong(position + BASE_OFFSET_OFFSET, baseOffset);
    buffer.putInt(position + LENGTH_OFFSET, sizeInBytes - LOG_OVERHEAD);
    buffer.putInt(position + PARTITION_LEADER_EPOCH_OFFSET, partitionLeaderEpoch);
    buffer.put(position + MAGIC_OFFSET, magic);
    buffer.putShort(position + ATTRIBUTES_OFFSET, attributes);
    buffer.putLong(position + BASE_TIMESTAMP_OFFSET, baseTimestamp);
    buffer.putLong(position + MAX_TIMESTAMP_OFFSET, maxTimestamp);
    buffer.putInt(position + LAST_OFFSET_DELTA_OFFSET, lastOffsetDelta);
    buffer.putLong(position + PRODUCER_ID_OFFSET, producerId);
    buffer.putShort(position + PRODUCER_EPOCH_OFFSET, epoch);
    buffer.putInt(position + BASE_SEQUENCE_OFFSET, sequence);
    buffer.putInt(position + RECORDS_COUNT_OFFSET, numRecords);
    long crc = Crc32C.compute(buffer, ATTRIBUTES_OFFSET, sizeInBytes - ATTRIBUTES_OFFSET);
    buffer.putInt(position + CRC_OFFSET, (int) crc);
    buffer.position(position + RECORD_BATCH_OVERHEAD);
}
 
開發者ID:YMCoding,項目名稱:kafka-0.11.0.0-src-with-comment,代碼行數:41,代碼來源:DefaultRecordBatch.java

示例15: getTransactionBytes

import java.nio.ByteBuffer; //導入方法依賴的package包/類
public byte[] getTransactionBytes( )
{
	ByteBuffer b = ByteBuffer.allocate( (creator.length + 8 ) * transactions.size() );
	b.order( ByteOrder.LITTLE_ENDIAN );
	for (AT_Transaction tx : transactions.values() )
	{
		b.put( tx.getRecipientId() );
		b.putLong( tx.getAmount() );
	}
	return b.array();

}
 
開發者ID:muhatzg,項目名稱:burstcoin,代碼行數:13,代碼來源:AT_Machine_State.java


注:本文中的java.nio.ByteBuffer.putLong方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。