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

x33g5p2x  于2022-01-16 转载在 其他  
字(4.2k)|赞(0)|评价(0)|浏览(197)

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

ByteBuffer.putChar介绍

[英]Writes the given char to the current position and increases the position by 2.

The char is converted to bytes using the current byte order.
[中]将给定字符写入当前位置,并将该位置增加2。
使用当前字节顺序将字符转换为字节。

代码示例

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

@Override
public void setChar(long byteIndex, char[] source, int elemoff, int numElems) {
  for ( int i=0; i <numElems; i++ ) {
    buffer.putChar((int) (byteIndex+2*i),source[i+elemoff]);
  }
}

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

@Override
public void putChar(long byteIndex, char c) {
  buffer.putChar((int) byteIndex, c);
}

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

@Override
public void writeString( char value )
{
  buf.putChar( value );
}

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

@Override
public CharBuffer put (int index, char c) {
  if (index < 0 || index >= limit) {
    throw new IndexOutOfBoundsException();
  }
  byteBuffer.putChar(index << 1, c);
  return this;
}

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

@Override
public CharBuffer put (int index, char c) {
  if (index < 0 || index >= limit) {
    throw new IndexOutOfBoundsException();
  }
  byteBuffer.putChar(index << 1, c);
  return this;
}

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

@Override
 public Hasher putChar(char c) {
  scratch.putChar(c);
  return update(Chars.BYTES);
 }
}

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

@Override
public final Hasher putChar(char c) {
 buffer.putChar(c);
 munchIfFull();
 return this;
}

代码示例来源: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 < len; i++) {
  buffer.putChar(input.charAt(i));
 }
 return hashBytes(buffer.array());
}

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

@Override
public CharBuffer put (char c) {
  if (position == limit) {
    throw new BufferOverflowException();
  }
  byteBuffer.putChar(position++ << 1, c);
  return this;
}

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

@Override
public void writeString( String value )
{
  final int len = value.length();
  buf.putInt( value.length() );
  for ( int i = 0; i < len; i++ )
  {
    final char c = value.charAt( i );
    buf.putChar( c );
  }
}

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

@Override
public CharBuffer put (char c) {
  if (position == limit) {
    throw new BufferOverflowException();
  }
  byteBuffer.putChar(position++ << 1, c);
  return this;
}

代码示例来源:origin: prestodb/presto

@Override
 public Hasher putChar(char c) {
  scratch.putChar(c);
  return update(Chars.BYTES);
 }
}

代码示例来源:origin: prestodb/presto

@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 < len; i++) {
  buffer.putChar(input.charAt(i));
 }
 return hashBytes(buffer.array());
}

代码示例来源:origin: prestodb/presto

@Override
public final Hasher putChar(char c) {
 buffer.putChar(c);
 munchIfFull();
 return this;
}

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

/**
 * Append the given {@code char} to this {@literal Buffer}.
 *
 * @param c The {@code char} to append.
 * @return {@literal this}
 */
public Buffer append(char c) {
  ensureCapacity(2);
  buffer.putChar(c);
  return this;
}

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

@Override
public final Hasher putChar(char c) {
 buffer.putChar(c);
 munchIfFull();
 return this;
}

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

@Override
 public Hasher putChar(char c) {
  scratch.putChar(c);
  return update(Chars.BYTES);
 }
}

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

/**
 * Prepend the given {@code char} to this existing {@literal Buffer}.
 *
 * @param c The {@code char} to prepend.
 * @return {@literal this}
 */
public Buffer prepend(char c) {
  shift(2);
  this.buffer.putChar(c);
  reset();
  return this;
}

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

public void testFromByteArray_withTooLongArrayInputThrowsIllegalArgumentException() {
 byte[] buffer = MANY_VALUES_PAIRED_STATS.toByteArray();
 byte[] tooLongByteArray =
   ByteBuffer.allocate(buffer.length + 2)
     .order(ByteOrder.LITTLE_ENDIAN)
     .put(buffer)
     .putChar('.')
     .array();
 try {
  PairedStats.fromByteArray(tooLongByteArray);
  fail("Expected IllegalArgumentException");
 } catch (IllegalArgumentException expected) {
 }
}

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

public void testFromByteArray_withTooLongArrayInputThrowsIllegalArgumentException() {
 byte[] buffer = MANY_VALUES_STATS_VARARGS.toByteArray();
 byte[] tooLongByteArray =
   ByteBuffer.allocate(buffer.length + 2)
     .order(ByteOrder.LITTLE_ENDIAN)
     .put(buffer)
     .putChar('.')
     .array();
 try {
  Stats.fromByteArray(tooLongByteArray);
  fail("Expected IllegalArgumentException");
 } catch (IllegalArgumentException expected) {
 }
}

相关文章