本文整理了Java中java.nio.ByteBuffer.getChar()
方法的一些代码示例,展示了ByteBuffer.getChar()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ByteBuffer.getChar()
方法的具体详情如下:
包路径:java.nio.ByteBuffer
类名称:ByteBuffer
方法名:getChar
[英]Returns the char at the current position and increases the position by 2.
The 2 bytes starting at the current position are composed into a char according to the current byte order and returned.
[中]返回当前位置的字符,并将该位置增加2。
从当前位置开始的2个字节根据当前字节顺序组成一个字符并返回。
代码示例来源:origin: redisson/redisson
@Override
public void getCharArr(long byteIndex, char[] target, int elemoff, int numElems) {
for ( int i=0; i <numElems; i++ ) {
target[i+elemoff] = buffer.getChar((int) (byteIndex+i*2));
}
}
代码示例来源:origin: redisson/redisson
@Override
public char getChar(long byteIndex) {
return buffer.getChar((int) byteIndex);
}
代码示例来源:origin: libgdx/libgdx
@Override
public char get (int index) {
if (index < 0 || index >= limit) {
throw new IndexOutOfBoundsException();
}
return byteBuffer.getChar(index << 1);
}
代码示例来源:origin: libgdx/libgdx
@Override
public char get (int index) {
if (index < 0 || index >= limit) {
throw new IndexOutOfBoundsException();
}
return byteBuffer.getChar(index << 1);
}
代码示例来源:origin: com.h2database/h2
@Override
public Object read(ByteBuffer buff, int tag) {
return buff.getChar();
}
代码示例来源:origin: bytedeco/javacpp
@Override public char getChar(long i) {
return buffer.getChar((int)i);
}
@Override public ByteIndexer putChar(long i, char c) {
代码示例来源:origin: robolectric/robolectric
ResTable_lib_entry(ByteBuffer buf, int offset) {
super(buf, offset);
packageId = buf.getInt(offset);
for (int i = 0; i < packageName.length; i++) {
packageName[i] = buf.getChar(offset + 4 + i * SIZEOF_SHORT);
}
}
};
代码示例来源:origin: libgdx/libgdx
@Override
public char get () {
if (position == limit) {
throw new BufferUnderflowException();
}
return byteBuffer.getChar(position++ << 1);
}
代码示例来源:origin: libgdx/libgdx
@Override
public char get () {
if (position == limit) {
throw new BufferUnderflowException();
}
return byteBuffer.getChar(position++ << 1);
}
代码示例来源:origin: redisson/redisson
/**
* Read the next {@code char} from the underlying {@link ByteBuffer}.
*
* @return The next {@code char}.
*/
public char readChar() {
if (null != buffer) {
return buffer.getChar();
}
throw new BufferUnderflowException();
}
代码示例来源:origin: neo4j/neo4j
private static CharArray readCharArray( ByteBuffer bb, int offset )
{
final int len = bb.getInt( offset );
offset += Integer.BYTES;
final char[] array = new char[len];
for ( int i = 0; i < len; i++ )
{
array[i] = bb.getChar( offset );
offset += Character.BYTES;
}
return charArray( array );
}
代码示例来源:origin: apache/incubator-pinot
private String get(final int index) {
int startOffset = _byteBuffer.getInt(index * Integer.BYTES);
int endOffset = _byteBuffer.capacity();
if (index > 0) {
endOffset = _byteBuffer.getInt((index - 1) * Integer.BYTES);
}
char[] chars = new char[(endOffset - startOffset) / Character.BYTES];
for (int i = 0, j = startOffset; i < chars.length; i++, j = j + Character.BYTES) {
chars[i] = _byteBuffer.getChar(j);
}
return new String(chars);
}
代码示例来源:origin: neo4j/neo4j
private static CharValue readChar( ByteBuffer chunk, int offset )
{
return charValue( chunk.getChar( offset ) );
}
代码示例来源:origin: neo4j/neo4j
private static String readRawString( ByteBuffer chunk, int offset )
{
final int len = chunk.getInt( offset );
if ( len == 0 )
{
return "";
}
offset += Integer.BYTES;
final char[] chars = new char[len];
for ( int i = 0; i < len; i++ )
{
chars[i] = chunk.getChar( offset );
offset += Character.BYTES;
}
return UnsafeUtil.newSharedArrayString( chars );
}
代码示例来源:origin: robolectric/robolectric
public ResTable_package(ByteBuffer buf, int offset) {
super(buf, offset);
header = new ResChunk_header(buf, offset);
id = buf.getInt(offset + ResChunk_header.SIZEOF);
for (int i = 0; i < name.length; i++) {
name[i] = buf.getChar(offset + ResChunk_header.SIZEOF + 4 + i * 2);
}
typeStrings = buf.getInt(offset + ResChunk_header.SIZEOF + 4 + 256);
lastPublicType = buf.getInt(offset + ResChunk_header.SIZEOF + 4 + 256 + 4);
keyStrings = buf.getInt(offset + ResChunk_header.SIZEOF + 4 + 256 + 8);
lastPublicKey = buf.getInt(offset + ResChunk_header.SIZEOF + 4 + 256 + 12);
typeIdOffset = buf.getInt(offset + ResChunk_header.SIZEOF + 4 + 256 + 16);
}
};
代码示例来源:origin: apache/ignite
/**
* {@inheritDoc}
*/
@Override public char readChar() throws IOException {
ensure(2);
return buf.getChar();
}
代码示例来源:origin: apache/ignite
/**
* {@inheritDoc}
*/
@Override public char readChar() throws IOException {
ensure(2);
return buf.getChar();
}
代码示例来源:origin: apache/ignite
/** {@inheritDoc} */
@Override public char[] readCharArray(int cnt) {
ensureHasData(2 * cnt);
char[] res = new char[cnt];
for (int i = 0; i < cnt; i++)
res[i] = buf.getChar();
return res;
}
代码示例来源:origin: apache/ignite
/**
* {@inheritDoc}
*/
@Override public char readChar() throws IOException {
ensure(2);
return buffer().getChar();
}
代码示例来源:origin: bytedeco/javacpp
@Override public char getChar(long i) {
if (RAW != null) {
return RAW.getChar(array, checkIndex(i, array.length - 1));
} else {
return getBuffer().getChar((int)i);
}
}
@Override public ByteIndexer putChar(long i, char c) {
内容来源于网络,如有侵权,请联系作者删除!