com.esotericsoftware.kryo.io.Input.readUtf8Length()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(5.9k)|赞(0)|评价(0)|浏览(100)

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

Input.readUtf8Length介绍

暂无

代码示例

代码示例来源:origin: com.esotericsoftware.kryo/kryo

/** Reads the length and string of UTF8 characters, or null. This can read strings written by {@link Output#writeString(String)}
 * , {@link Output#writeString(CharSequence)}, and {@link Output#writeAscii(String)}.
 * @return May be null. */
public StringBuilder readStringBuilder () {
  int available = require(1);
  int b = buffer[position++];
  if ((b & 0x80) == 0) return new StringBuilder(readAscii()); // ASCII.
  // Null, empty, or UTF8.
  int charCount = available >= 5 ? readUtf8Length(b) : readUtf8Length_slow(b);
  switch (charCount) {
  case 0:
    return null;
  case 1:
    return new StringBuilder("");
  }
  charCount--;
  if (chars.length < charCount) chars = new char[charCount];
  readUtf8(charCount);
  StringBuilder builder = new StringBuilder(charCount);
  builder.append(chars, 0, charCount);
  return builder;
}

代码示例来源:origin: com.esotericsoftware/kryo-shaded

/** Reads the length and string of UTF8 characters, or null. This can read strings written by
 * {@link Output#writeString(String)} , {@link Output#writeString(CharSequence)}, and {@link Output#writeAscii(String)}.
 * @return May be null. */
public String readString () {
  int available = require(1);
  int b = buffer[position++];
  if ((b & 0x80) == 0) return readAscii(); // ASCII.
  // Null, empty, or UTF8.
  int charCount = available >= 5 ? readUtf8Length(b) : readUtf8Length_slow(b);
  switch (charCount) {
  case 0:
    return null;
  case 1:
    return "";
  }
  charCount--;
  if (chars.length < charCount) chars = new char[charCount];
  readUtf8(charCount);
  return new String(chars, 0, charCount);
}

代码示例来源:origin: com.esotericsoftware/kryo

/** Reads the length and string of UTF8 characters, or null. This can read strings written by
 * {@link Output#writeString(String)} , {@link Output#writeString(CharSequence)}, and {@link Output#writeAscii(String)}.
 * @return May be null. */
public String readString () {
  int available = require(1);
  int b = buffer[position++];
  if ((b & 0x80) == 0) return readAscii(); // ASCII.
  // Null, empty, or UTF8.
  int charCount = available >= 5 ? readUtf8Length(b) : readUtf8Length_slow(b);
  switch (charCount) {
  case 0:
    return null;
  case 1:
    return "";
  }
  charCount--;
  if (chars.length < charCount) chars = new char[charCount];
  readUtf8(charCount);
  return new String(chars, 0, charCount);
}

代码示例来源:origin: com.esotericsoftware/kryo

/** Reads the length and string of UTF8 characters, or null. This can read strings written by
 * {@link Output#writeString(String)} , {@link Output#writeString(CharSequence)}, and {@link Output#writeAscii(String)}.
 * @return May be null. */
public StringBuilder readStringBuilder () {
  int available = require(1);
  int b = buffer[position++];
  if ((b & 0x80) == 0) return new StringBuilder(readAscii()); // ASCII.
  // Null, empty, or UTF8.
  int charCount = available >= 5 ? readUtf8Length(b) : readUtf8Length_slow(b);
  switch (charCount) {
  case 0:
    return null;
  case 1:
    return new StringBuilder("");
  }
  charCount--;
  if (chars.length < charCount) chars = new char[charCount];
  readUtf8(charCount);
  StringBuilder builder = new StringBuilder(charCount);
  builder.append(chars, 0, charCount);
  return builder;
}

代码示例来源:origin: svn2github/kryo

/** Reads the length and string of UTF8 characters, or null. This can read strings written by {@link Output#writeString(String)}
 * , {@link Output#writeString(CharSequence)}, and {@link Output#writeAscii(String)}.
 * @return May be null. */
public StringBuilder readStringBuilder () {
  int available = require(1);
  int b = buffer[position++];
  if ((b & 0x80) == 0) return new StringBuilder(readAscii()); // ASCII.
  // Null, empty, or UTF8.
  int charCount = available >= 5 ? readUtf8Length(b) : readUtf8Length_slow(b);
  switch (charCount) {
  case 0:
    return null;
  case 1:
    return new StringBuilder("");
  }
  charCount--;
  if (chars.length < charCount) chars = new char[charCount];
  readUtf8(charCount);
  StringBuilder builder = new StringBuilder(charCount);
  builder.append(chars, 0, charCount);
  return builder;
}

代码示例来源:origin: com.esotericsoftware/kryo-shaded

/** Reads the length and string of UTF8 characters, or null. This can read strings written by
 * {@link Output#writeString(String)} , {@link Output#writeString(CharSequence)}, and {@link Output#writeAscii(String)}.
 * @return May be null. */
public StringBuilder readStringBuilder () {
  int available = require(1);
  int b = buffer[position++];
  if ((b & 0x80) == 0) return new StringBuilder(readAscii()); // ASCII.
  // Null, empty, or UTF8.
  int charCount = available >= 5 ? readUtf8Length(b) : readUtf8Length_slow(b);
  switch (charCount) {
  case 0:
    return null;
  case 1:
    return new StringBuilder("");
  }
  charCount--;
  if (chars.length < charCount) chars = new char[charCount];
  readUtf8(charCount);
  StringBuilder builder = new StringBuilder(charCount);
  builder.append(chars, 0, charCount);
  return builder;
}

代码示例来源:origin: com.esotericsoftware.kryo/kryo

/** Reads the length and string of UTF8 characters, or null. This can read strings written by {@link Output#writeString(String)}
 * , {@link Output#writeString(CharSequence)}, and {@link Output#writeAscii(String)}.
 * @return May be null. */
public String readString () {
  int available = require(1);
  int b = buffer[position++];
  if ((b & 0x80) == 0) return readAscii(); // ASCII.
  // Null, empty, or UTF8.
  int charCount = available >= 5 ? readUtf8Length(b) : readUtf8Length_slow(b);
  switch (charCount) {
  case 0:
    return null;
  case 1:
    return "";
  }
  charCount--;
  if (chars.length < charCount) chars = new char[charCount];
  readUtf8(charCount);
  return new String(chars, 0, charCount);
}

代码示例来源:origin: svn2github/kryo

/** Reads the length and string of UTF8 characters, or null. This can read strings written by {@link Output#writeString(String)}
 * , {@link Output#writeString(CharSequence)}, and {@link Output#writeAscii(String)}.
 * @return May be null. */
public String readString () {
  int available = require(1);
  int b = buffer[position++];
  if ((b & 0x80) == 0) return readAscii(); // ASCII.
  // Null, empty, or UTF8.
  int charCount = available >= 5 ? readUtf8Length(b) : readUtf8Length_slow(b);
  switch (charCount) {
  case 0:
    return null;
  case 1:
    return "";
  }
  charCount--;
  if (chars.length < charCount) chars = new char[charCount];
  readUtf8(charCount);
  return new String(chars, 0, charCount);
}

相关文章

微信公众号

最新文章

更多