本文整理匯總了Java中com.google.protobuf.ByteString.newInput方法的典型用法代碼示例。如果您正苦於以下問題:Java ByteString.newInput方法的具體用法?Java ByteString.newInput怎麽用?Java ByteString.newInput使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.protobuf.ByteString
的用法示例。
在下文中一共展示了ByteString.newInput方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: uncompressByteString
import com.google.protobuf.ByteString; //導入方法依賴的package包/類
private static byte[] uncompressByteString(ByteString bs, Dictionary dict) throws IOException {
InputStream in = bs.newInput();
byte status = (byte)in.read();
if (status == Dictionary.NOT_IN_DICTIONARY) {
byte[] arr = new byte[StreamUtils.readRawVarint32(in)];
int bytesRead = in.read(arr);
if (bytesRead != arr.length) {
throw new IOException("Cannot read; wanted " + arr.length + ", but got " + bytesRead);
}
if (dict != null) dict.addEntry(arr, 0, arr.length);
return arr;
} else {
// Status here is the higher-order byte of index of the dictionary entry.
short dictIdx = StreamUtils.toShort(status, (byte)in.read());
byte[] entry = dict.getEntry(dictIdx);
if (entry == null) {
throw new IOException("Missing dictionary entry for index " + dictIdx);
}
return entry;
}
}
示例2: readMessageList
import com.google.protobuf.ByteString; //導入方法依賴的package包/類
/**
* Reads a list of protos, using the provided parser, from the provided {@link ByteString}.
* @throws IOException if the proto list could not be parsed.
*/
public static <T extends MessageLite> List<T> readMessageList(
ByteString bytes,
Parser<T> parser)
throws IOException {
InputStream stream = bytes.newInput();
return readMessageList(stream, parser);
}
示例3: advance
import com.google.protobuf.ByteString; //導入方法依賴的package包/類
private void advance() {
ByteString data = ByteString.EMPTY;
while (iterator.hasNext() && data.isEmpty()) {
data = iterator.next();
}
input = data.newInput();
}
示例4: Chunker
import com.google.protobuf.ByteString; //導入方法依賴的package包/類
public Chunker(ByteString data, int chunkSize) {
this(() -> data.newInput(), Digests.computeDigest(data), chunkSize);
}