java.io.DataOutputStream.writeChar()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(5.8k)|赞(0)|评价(0)|浏览(178)

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

DataOutputStream.writeChar介绍

[英]Writes a char to the underlying output stream as a 2-byte value, high byte first. If no exception is thrown, the counter written is incremented by 2.
[中]将char作为2字节值写入基础输出流,高字节优先。如果未引发异常,计数器written将递增2

代码示例

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

@Override
public final void writeChar(int v) throws IOException {
  out.writeChar(v);
}

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

public final void writeChar (int v) throws IOException {
  dos.writeChar(v);
}

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

public final void writeChar (int v) throws IOException {
  dos.writeChar(v);
}

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

@Override
public final void writeChar(int v) throws IOException {
  out.writeChar(v);
}

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

@Override
public boolean keyTyped (char character) {
  synchronized (this) {
    if (!connected) return false;
  }
  try {
    out.writeInt(KEY_TYPED);
    out.writeChar(character);
  } catch (Throwable t) {
    synchronized (this) {
      connected = false;
    }
  }
  return false;
}

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

@Override
public boolean keyTyped (char character) {
  synchronized (this) {
    if (!connected) return false;
  }
  try {
    out.writeInt(KEY_TYPED);
    out.writeChar(character);
  } catch (Throwable t) {
    synchronized (this) {
      connected = false;
    }
  }
  return false;
}

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

@Override
public final void writeChar(int v) throws IOException {
  out.writeChar(v);
}

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

@Override
public void writeChar(int v) throws IOException
{
  m_dataOutputStream.writeChar(v);
}

代码示例来源:origin: hankcs/HanLP

@Override
public void save(DataOutputStream out) throws Exception
{
  out.writeChar(letter);
  out.writeByte(isAcceptNode ? 1 : 0);
  out.writeInt(transitionSetBeginIndex);
  out.writeInt(transitionSetSize);
}

代码示例来源:origin: hankcs/HanLP

@Override
public void save(DataOutputStream out) throws Exception
{
  out.writeInt(o.length);
  for (char c : o)
  {
    out.writeChar(c);
  }
  out.writeInt(w.length);
  for (double v : w)
  {
    out.writeDouble(v);
  }
}

代码示例来源:origin: hankcs/HanLP

/**
 * 简单好用的写String方式
 *
 * @param s
 * @param out
 * @throws IOException
 */
public static void writeString(String s, DataOutputStream out) throws IOException
{
  out.writeInt(s.length());
  for (char c : s.toCharArray())
  {
    out.writeChar(c);
  }
}

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

/** Appends a {@code char} value to the stream. Because, in Java, a {@code char} is 16 bytes, this corresponds to the
 * {@code int16} value type in the UBJSON specification.
 * @return this writer, for chaining */
public UBJsonWriter value (char value) throws IOException {
  checkName();
  out.writeByte('I');
  out.writeChar(value);
  return this;
}

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

/** Appends a {@code char} value to the stream. Because, in Java, a {@code char} is 16 bytes, this corresponds to the
 * {@code int16} value type in the UBJSON specification.
 * @return this writer, for chaining */
public UBJsonWriter value (char value) throws IOException {
  checkName();
  out.writeByte('I');
  out.writeChar(value);
  return this;
}

代码示例来源:origin: apache/incubator-pinot

public void setColumn(int colId, @Nonnull char[] values)
  throws IOException {
 _currentRowDataByteBuffer.position(_columnOffsets[colId]);
 _currentRowDataByteBuffer.putInt(_variableSizeDataByteArrayOutputStream.size());
 _currentRowDataByteBuffer.putInt(values.length);
 for (char value : values) {
  _variableSizeDataOutputStream.writeChar(value);
 }
}

代码示例来源:origin: hankcs/HanLP

protected void walkToSave(DataOutputStream out) throws IOException
{
  out.writeChar(c);
  out.writeInt(status.ordinal());
  int childSize = 0;
  if (child != null) childSize = child.length;
  out.writeInt(childSize);
  if (child == null) return;
  for (BaseNode node : child)
  {
    node.walkToSave(out);
  }
}

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

/** Appends an optimized {@code char array} value to the stream. As an optimized array, the {@code int16} value type marker and
 * element count are encoded once at the array marker instead of repeating the type marker for each element.
 * @return this writer, for chaining */
public UBJsonWriter value (char[] values) throws IOException {
  array();
  out.writeByte('$');
  out.writeByte('C');
  out.writeByte('#');
  value(values.length);
  for (int i = 0, n = values.length; i < n; i++) {
    out.writeChar(values[i]);
  }
  pop(true);
  return this;
}

代码示例来源:origin: hankcs/HanLP

/**
 * 保存dat到磁盘
 * @param map
 * @return
 */
static boolean saveDat(TreeMap<String, Character> map)
{
  try
  {
    DataOutputStream out = new DataOutputStream(new BufferedOutputStream(IOUtil.newOutputStream(path + Predefine.VALUE_EXT)));
    out.writeInt(map.size());
    for (Character character : map.values())
    {
      out.writeChar(character);
    }
    out.close();
  }
  catch (Exception e)
  {
    logger.warning("保存值" + path + Predefine.VALUE_EXT + "失败" + e);
    return false;
  }
  return trie.save(path + Predefine.TRIE_EXT);
}

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

/** Appends an optimized {@code char array} value to the stream. As an optimized array, the {@code int16} value type marker and
 * element count are encoded once at the array marker instead of repeating the type marker for each element.
 * @return this writer, for chaining */
public UBJsonWriter value (char[] values) throws IOException {
  array();
  out.writeByte('$');
  out.writeByte('C');
  out.writeByte('#');
  value(values.length);
  for (int i = 0, n = values.length; i < n; i++) {
    out.writeChar(values[i]);
  }
  pop(true);
  return this;
}

代码示例来源:origin: hankcs/HanLP

@Override
public void save(DataOutputStream out) throws Exception
{
  simplify();
  out.writeInt(charTreeSet.size());
  for (Character character : charTreeSet)
  {
    out.writeChar(character);
  }
  simplifiedSourceNode.save(out);
  out.writeInt(mdagDataArray.length);
  for (SimpleMDAGNode simpleMDAGNode : mdagDataArray)
  {
    simpleMDAGNode.save(out);
  }
}

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

private void initializeData(DataOutputStream out) throws IOException {
 /* Write out various test values NORMALLY */
 out.write(new byte[] {-100, 100});
 out.writeBoolean(true);
 out.writeBoolean(false);
 out.writeByte(100);
 out.writeByte(-100);
 out.writeByte((byte) 200);
 out.writeChar('a');
 out.writeShort((short) -30000);
 out.writeShort((short) 50000);
 out.writeInt(0xCAFEBABE);
 out.writeLong(0xDEADBEEFCAFEBABEL);
 out.writeUTF("Herby Derby");
 out.writeFloat(Float.intBitsToFloat(0xCAFEBABE));
 out.writeDouble(Double.longBitsToDouble(0xDEADBEEFCAFEBABEL));
}

相关文章