Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.bukkit.craftbukkit.util;
- import java.io.DataInputStream;
- import java.io.DataOutputStream;
- import java.io.IOException;
- public class VarInt {
- public static long read(DataInputStream stream) throws IOException {
- long value = 0;
- byte b;
- while((b = stream.readByte()) >= 0) {
- value = (value << 8) + b;
- }
- return (value << 8) + b + 128;
- }
- public static void write(DataOutputStream stream, long l) throws IOException {
- int count = 64 - Long.numberOfLeadingZeros(l);
- count -= count % 7;
- for (int i = count; i > 0; i -=7) {
- stream.writeByte((int) ((l >>> i) & 0x3F));
- }
- stream.write((int) ((l & 0x3F) - 128));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment