热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

java.nio.ByteBuffer.order()方法的使用及代码示例

本文整理了Java中java.nio.ByteBuffer.order()方法的一些代码示例,展示了ByteBuffer.order()的具体

本文整理了Java中java.nio.ByteBuffer.order()方法的一些代码示例,展示了ByteBuffer.order()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ByteBuffer.order()方法的具体详情如下:
包路径:java.nio.ByteBuffer
类名称:ByteBuffer
方法名:order

ByteBuffer.order介绍

[英]The byte order of this buffer, default is BIG_ENDIAN.
[中]此缓冲区的字节顺序,默认为BIG_ENDIAN。

代码示例

代码示例来源:origin: Tencent/tinker

/**
* Creates a new empty dex of the specified size.
*/
public Dex(int byteCount) {
this.data = ByteBuffer.wrap(new byte[byteCount]);
this.data.order(ByteOrder.LITTLE_ENDIAN);
this.tableOfContents.fileSize = byteCount;
}

代码示例来源:origin: libgdx/libgdx

public static ByteBuffer newByteBuffer (int numBytes) {
ByteBuffer buffer = ByteBuffer.allocateDirect(numBytes);
buffer.order(ByteOrder.nativeOrder());
return buffer;
}

代码示例来源:origin: bumptech/glide

RandomAccessReader(byte[] data, int length) {
this.data = (ByteBuffer) ByteBuffer.wrap(data)
.order(ByteOrder.BIG_ENDIAN)
.limit(length);
}

代码示例来源:origin: google/guava

@Override
public HashCode hashUnencodedChars(CharSequence input) {
int len = input.length();
ByteBuffer buffer = ByteBuffer.allocate(len * 2).order(ByteOrder.LITTLE_ENDIAN);
for (int i = 0; i buffer.putChar(input.charAt(i));
}
return hashBytes(buffer.array());
}

代码示例来源:origin: neo4j/neo4j

private static ByteBuffer grow( ByteBuffer buffer, int required )
{
buffer.flip();
int capacity = buffer.capacity();
do
{
capacity *= 2;
}
while ( capacity - buffer.limit() return ByteBuffer.allocate( capacity ).order( ByteOrder.LITTLE_ENDIAN ).put( buffer );
}

代码示例来源:origin: apache/flink

private static String deserializeV1(byte[] serialized) {
final ByteBuffer bb = ByteBuffer.wrap(serialized).order(ByteOrder.LITTLE_ENDIAN);
final byte[] targetStringBytes = new byte[bb.getInt()];
bb.get(targetStringBytes);
return new String(targetStringBytes, CHARSET);
}

代码示例来源:origin: stackoverflow.com

public static int byteArrayToLeInt(byte[] b) {
final ByteBuffer bb = ByteBuffer.wrap(b);
bb.order(ByteOrder.LITTLE_ENDIAN);
return bb.getInt();
}
public static byte[] leIntToByteArray(int i) {
final ByteBuffer bb = ByteBuffer.allocate(Integer.SIZE / Byte.SIZE);
bb.order(ByteOrder.LITTLE_ENDIAN);
bb.putInt(i);
return bb.array();
}

代码示例来源:origin: pxb1988/dex2jar

private static ByteBuffer slice(ByteBuffer in, int offset, int length) {
in.position(offset);
ByteBuffer b = in.slice();
b.limit(length);
b.order(ByteOrder.LITTLE_ENDIAN);
return b;
}

代码示例来源:origin: Tencent/tinker

private void ensureBufferSize(int bytes) {
if (this.data.position() + bytes > this.data.limit()) {
if (this.isResizeAllowed) {
byte[] array = this.data.array();
byte[] newArray = new byte[array.length + bytes + (array.length >> 1)];
System.arraycopy(array, 0, newArray, 0, this.data.position());
int lastPos = this.data.position();
this.data = ByteBuffer.wrap(newArray);
this.data.order(ByteOrder.LITTLE_ENDIAN);
this.data.position(lastPos);
this.data.limit(this.data.capacity());
}
}
}

代码示例来源:origin: libgdx/libgdx

void setup (byte[] pcm, int channels, int sampleRate) {
int bytes = pcm.length - (pcm.length % (channels > 1 ? 4 : 2));
int samples = bytes / (2 * channels);
duration = samples / (float)sampleRate;
ByteBuffer buffer = ByteBuffer.allocateDirect(bytes);
buffer.order(ByteOrder.nativeOrder());
buffer.put(pcm, 0, bytes);
buffer.flip();
if (bufferID == -1) {
bufferID = alGenBuffers();
alBufferData(bufferID, channels > 1 ? AL_FORMAT_STEREO16 : AL_FORMAT_MONO16, buffer.asShortBuffer(), sampleRate);
}
}

代码示例来源:origin: google/guava

@Override
public HashCode makeHash() {
h1 ^= length;
h2 ^= length;
h1 += h2;
h2 += h1;
h1 = fmix64(h1);
h2 = fmix64(h2);
h1 += h2;
h2 += h1;
return HashCode.fromBytesNoCopy(
ByteBuffer.wrap(new byte[CHUNK_SIZE])
.order(ByteOrder.LITTLE_ENDIAN)
.putLong(h1)
.putLong(h2)
.array());
}

代码示例来源:origin: google/ExoPlayer

@Override
public void queueInput(ByteBuffer inputBuffer) {
Assertions.checkState(outputChannels != null);
int position = inputBuffer.position();
int limit = inputBuffer.limit();
int frameCount = (limit - position) / (2 * channelCount);
int outputSize = frameCount * outputChannels.length * 2;
if (buffer.capacity() buffer = ByteBuffer.allocateDirect(outputSize).order(ByteOrder.nativeOrder());
} else {
buffer.clear();
}
while (position for (int channelIndex : outputChannels) {
buffer.putShort(inputBuffer.getShort(position + 2 * channelIndex));
}
position += channelCount * 2;
}
inputBuffer.position(limit);
buffer.flip();
outputBuffer = buffer;
}

代码示例来源:origin: apache/flink

@Override
public byte[] serialize(String value) {
final byte[] serialized = value.getBytes(StandardCharsets.UTF_8);
final byte[] targetBytes = new byte[Integer.BYTES + serialized.length];
final ByteBuffer bb = ByteBuffer.wrap(targetBytes).order(ByteOrder.LITTLE_ENDIAN);
bb.putInt(serialized.length);
bb.put(serialized);
return targetBytes;
}

代码示例来源:origin: Tencent/tinker

public DexDataBuffer() {
this.data = ByteBuffer.allocate(DEFAULT_BUFFER_SIZE);
this.data.order(ByteOrder.LITTLE_ENDIAN);
this.dataBound = this.data.position();
this.data.limit(this.data.capacity());
this.isResizeAllowed = true;
}

代码示例来源:origin: google/guava

@Override
public HashCode hashLong(long input) {
return hashBytes(ByteBuffer.allocate(8).order(ByteOrder.LITTLE_ENDIAN).putLong(input).array());
}

代码示例来源:origin: h2oai/h2o-2

/** Read from a fixed byte[]; should not be closed. */
AutoBuffer( byte[] buf, int off ) {
assert buf != null : "null fed to ByteBuffer.wrap";
_bb = ByteBuffer.wrap(buf).order(ByteOrder.nativeOrder());
_bb.position(off);
_chan = null;
_h2o = null;
_read = true;
_firstPage = true;
_persist = 0; // No persistance
}

代码示例来源:origin: apache/hive

public Binary toBinary() {
ByteBuffer buf = ByteBuffer.allocate(12);
buf.order(ByteOrder.LITTLE_ENDIAN);
buf.putLong(timeOfDayNanos);
buf.putInt(julianDay);
buf.flip();
return Binary.fromByteBuffer(buf);
}

代码示例来源:origin: google/ExoPlayer

/**
* Initializes the buffer.
*
* @param timeUs The presentation timestamp for the buffer, in microseconds.
* @param size An upper bound on the size of the data that will be written to the buffer.
* @return The {@link #data} buffer, for convenience.
*/
public ByteBuffer init(long timeUs, int size) {
this.timeUs = timeUs;
if (data == null || data.capacity() data = ByteBuffer.allocateDirect(size).order(ByteOrder.nativeOrder());
}
data.position(0);
data.limit(size);
return data;
}

代码示例来源:origin: google/guava

/**
* Gets a byte array representation of this instance.
*
*

Note: No guarantees are made regarding stability of the representation between
* versions.
*/
public byte[] toByteArray() {
ByteBuffer buff = ByteBuffer.allocate(BYTES).order(ByteOrder.LITTLE_ENDIAN);
writeTo(buff);
return buff.array();
}

代码示例来源:origin: google/guava

/**
* Gets a byte array representation of this instance.
*
*

Note: No guarantees are made regarding stability of the representation between
* versions.
*/
public byte[] toByteArray() {
ByteBuffer buffer = ByteBuffer.allocate(BYTES).order(ByteOrder.LITTLE_ENDIAN);
xStats.writeTo(buffer);
yStats.writeTo(buffer);
buffer.putDouble(sumOfProductsOfDeltas);
return buffer.array();
}

推荐阅读
  • CF:3D City Model(小思维)问题解析和代码实现
    本文通过解析CF:3D City Model问题,介绍了问题的背景和要求,并给出了相应的代码实现。该问题涉及到在一个矩形的网格上建造城市的情景,每个网格单元可以作为建筑的基础,建筑由多个立方体叠加而成。文章详细讲解了问题的解决思路,并给出了相应的代码实现供读者参考。 ... [详细]
  • 本文介绍了设计师伊振华受邀参与沈阳市智慧城市运行管理中心项目的整体设计,并以数字赋能和创新驱动高质量发展的理念,建设了集成、智慧、高效的一体化城市综合管理平台,促进了城市的数字化转型。该中心被称为当代城市的智能心脏,为沈阳市的智慧城市建设做出了重要贡献。 ... [详细]
  • 电话号码的字母组合解题思路和代码示例
    本文介绍了力扣题目《电话号码的字母组合》的解题思路和代码示例。通过使用哈希表和递归求解的方法,可以将给定的电话号码转换为对应的字母组合。详细的解题思路和代码示例可以帮助读者更好地理解和实现该题目。 ... [详细]
  • Linux重启网络命令实例及关机和重启示例教程
    本文介绍了Linux系统中重启网络命令的实例,以及使用不同方式关机和重启系统的示例教程。包括使用图形界面和控制台访问系统的方法,以及使用shutdown命令进行系统关机和重启的句法和用法。 ... [详细]
  • baresip android编译、运行教程1语音通话
    本文介绍了如何在安卓平台上编译和运行baresip android,包括下载相关的sdk和ndk,修改ndk路径和输出目录,以及创建一个c++的安卓工程并将目录考到cpp下。详细步骤可参考给出的链接和文档。 ... [详细]
  • Python正则表达式学习记录及常用方法
    本文记录了学习Python正则表达式的过程,介绍了re模块的常用方法re.search,并解释了rawstring的作用。正则表达式是一种方便检查字符串匹配模式的工具,通过本文的学习可以掌握Python中使用正则表达式的基本方法。 ... [详细]
  • 自动轮播,反转播放的ViewPagerAdapter的使用方法和效果展示
    本文介绍了如何使用自动轮播、反转播放的ViewPagerAdapter,并展示了其效果。该ViewPagerAdapter支持无限循环、触摸暂停、切换缩放等功能。同时提供了使用GIF.gif的示例和github地址。通过LoopFragmentPagerAdapter类的getActualCount、getActualItem和getActualPagerTitle方法可以实现自定义的循环效果和标题展示。 ... [详细]
  • 标题: ... [详细]
  • 先看官方文档TheJavaTutorialshavebeenwrittenforJDK8.Examplesandpracticesdescribedinthispagedontta ... [详细]
  • 本文介绍了在处理不规则数据时如何使用Python自动提取文本中的时间日期,包括使用dateutil.parser模块统一日期字符串格式和使用datefinder模块提取日期。同时,还介绍了一段使用正则表达式的代码,可以支持中文日期和一些特殊的时间识别,例如'2012年12月12日'、'3小时前'、'在2012/12/13哈哈'等。 ... [详细]
  • 本文介绍了一个适用于PHP应用快速接入TRX和TRC20数字资产的开发包,该开发包支持使用自有Tron区块链节点的应用场景,也支持基于Tron官方公共API服务的轻量级部署场景。提供的功能包括生成地址、验证地址、查询余额、交易转账、查询最新区块和查询交易信息等。详细信息可参考tron-php的Github地址:https://github.com/Fenguoz/tron-php。 ... [详细]
  • 本文讨论了在VMWARE5.1的虚拟服务器Windows Server 2008R2上安装oracle 10g客户端时出现的问题,并提供了解决方法。错误日志显示了异常访问违例,通过分析日志中的问题帧,找到了解决问题的线索。文章详细介绍了解决方法,帮助读者顺利安装oracle 10g客户端。 ... [详细]
  • 使用C++编写程序实现增加或删除桌面的右键列表项
    本文介绍了使用C++编写程序实现增加或删除桌面的右键列表项的方法。首先通过操作注册表来实现增加或删除右键列表项的目的,然后使用管理注册表的函数来编写程序。文章详细介绍了使用的五种函数:RegCreateKey、RegSetValueEx、RegOpenKeyEx、RegDeleteKey和RegCloseKey,并给出了增加一项的函数写法。通过本文的方法,可以方便地自定义桌面的右键列表项。 ... [详细]
  • 本文整理了Java中java.lang.NoSuchMethodError.getMessage()方法的一些代码示例,展示了NoSuchMethodErr ... [详细]
  • 本文整理了Java中com.evernote.android.job.JobRequest.getTransientExtras()方法的一些代码示例,展示了 ... [详细]
author-avatar
用户691sf34d0b
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有