本文整理匯總了Java中com.google.protobuf.CodedOutputStream.writeSInt64NoTag方法的典型用法代碼示例。如果您正苦於以下問題:Java CodedOutputStream.writeSInt64NoTag方法的具體用法?Java CodedOutputStream.writeSInt64NoTag怎麽用?Java CodedOutputStream.writeSInt64NoTag使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.protobuf.CodedOutputStream
的用法示例。
在下文中一共展示了CodedOutputStream.writeSInt64NoTag方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testVarInt
import com.google.protobuf.CodedOutputStream; //導入方法依賴的package包/類
@Test
public void testVarInt() throws Exception {
//byte[] thingy = new byte[50];
long[] lengths = {1, 20, 200, 1024, 2048, 4000, 10000, 50000,
100000, 1024 * 1024,
((long) Integer.MAX_VALUE) * 100,
-1, -200, -5000};
for (long value : lengths) {
// do the test:
ByteBufferOutputStream bbos = new ByteBufferOutputStream(12);
CodedOutputStream cos = CodedOutputStream.newInstance(bbos);
long newvalue = (value << 4) | 8;
//cos.writeRawVarint64(newvalue);
cos.writeSInt64NoTag(newvalue);
cos.flush();
ByteBuffer bb = bbos.getByteBuffer();
System.out.println("value: " + value + ", length: " + bb.remaining());
ByteBufferInputStream bbis = new ByteBufferInputStream(bb);
CodedInputStream cis = CodedInputStream.newInstance(bbis);
long outval = cis.readSInt64();
long actual = outval >> 4;
long tag = outval & 0x0F;
System.out.println(" transformed we are: " + outval + " actual: " + actual + " tag: " + tag);
}
}