本文整理汇总了Java中com.google.common.io.ByteArrayDataInput.readFully方法的典型用法代码示例。如果您正苦于以下问题:Java ByteArrayDataInput.readFully方法的具体用法?Java ByteArrayDataInput.readFully怎么用?Java ByteArrayDataInput.readFully使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.io.ByteArrayDataInput
的用法示例。
在下文中一共展示了ByteArrayDataInput.readFully方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onPluginMessageReceived
import com.google.common.io.ByteArrayDataInput; //导入方法依赖的package包/类
public void onPluginMessageReceived(String channel, Player player, byte[] message) {
if (!channel.equals("BungeeCord")) {
return;
}
ByteArrayDataInput in = ByteStreams.newDataInput(message);
String subchannel = in.readUTF();
if (subchannel.equals("SkyWarsReloadedRequest")) {
short len = in.readShort();
byte[] msgbytes = new byte[len];
in.readFully(msgbytes);
Game game = gc.getGame(1);
if (game != null) {
BungeeUtil.sendSignUpdateRequest(game);
} else {
System.out.println("Game " + game + " couldn't be found, please fix your setup.");
}
}
}
示例2: readPatch
import com.google.common.io.ByteArrayDataInput; //导入方法依赖的package包/类
private ClassPatch readPatch(JarEntry entry, JarInputStream jis){
ByteArrayDataInput input;
try{
input = ByteStreams.newDataInput(ByteStreams.toByteArray(jis));
}catch(IOException e){
logger.warn("Unable to read binpatch file {}. Ignoring it", entry.getName());
return null;
}
String name = input.readUTF();
String sourceName = input.readUTF();
String targetName = input.readUTF();
boolean exists = input.readBoolean();
int inputChecksum = exists ? input.readInt() : 0;
int patchLength = input.readInt();
byte[] patchBytes = new byte[patchLength];
input.readFully(patchBytes);
return new ClassPatch(name, sourceName, targetName, exists, inputChecksum, patchBytes);
}
示例3: consumePacket
import com.google.common.io.ByteArrayDataInput; //导入方法依赖的package包/类
@Override
public FMLPacket consumePacket(byte[] data)
{
ByteArrayDataInput bdi = ByteStreams.newDataInput(data);
int chunkIdx = UnsignedBytes.toInt(bdi.readByte());
int chunkTotal = UnsignedBytes.toInt(bdi.readByte());
int chunkLength = bdi.readInt();
if (partials == null)
{
partials = new byte[chunkTotal][];
}
partials[chunkIdx] = new byte[chunkLength];
bdi.readFully(partials[chunkIdx]);
for (int i = 0; i < partials.length; i++)
{
if (partials[i] == null)
{
return null;
}
}
return this;
}
示例4: accept
import com.google.common.io.ByteArrayDataInput; //导入方法依赖的package包/类
@Override
public boolean accept(Player receiver, ByteArrayDataInput in) {
short len = in.readShort();
byte[] data = new byte[len];
in.readFully(data);
return callback.test(data);
}
示例5: readPatch
import com.google.common.io.ByteArrayDataInput; //导入方法依赖的package包/类
private ClassPatch readPatch(JarEntry patchEntry, JarInputStream jis)
{
if (DEBUG)
FMLRelaunchLog.finer("Reading patch data from %s", patchEntry.getName());
ByteArrayDataInput input;
try
{
input = ByteStreams.newDataInput(ByteStreams.toByteArray(jis));
}
catch (IOException e)
{
FMLRelaunchLog.log(Level.WARN, e, "Unable to read binpatch file %s - ignoring", patchEntry.getName());
return null;
}
String name = input.readUTF();
String sourceClassName = input.readUTF();
String targetClassName = input.readUTF();
boolean exists = input.readBoolean();
int inputChecksum = 0;
if (exists)
{
inputChecksum = input.readInt();
}
int patchLength = input.readInt();
byte[] patchBytes = new byte[patchLength];
input.readFully(patchBytes);
return new ClassPatch(name, sourceClassName, targetClassName, exists, inputChecksum, patchBytes);
}
示例6: readPatch
import com.google.common.io.ByteArrayDataInput; //导入方法依赖的package包/类
private ClassPatch readPatch(JarEntry patchEntry, JarInputStream jis)
{
FMLRelaunchLog.finer("Reading patch data from %s", patchEntry.getName());
ByteArrayDataInput input;
try
{
input = ByteStreams.newDataInput(ByteStreams.toByteArray(jis));
}
catch (IOException e)
{
FMLRelaunchLog.log(Level.WARN, e, "Unable to read binpatch file %s - ignoring", patchEntry.getName());
return null;
}
String name = input.readUTF();
String sourceClassName = input.readUTF();
String targetClassName = input.readUTF();
boolean exists = input.readBoolean();
int inputChecksum = 0;
if (exists)
{
inputChecksum = input.readInt();
}
int patchLength = input.readInt();
byte[] patchBytes = new byte[patchLength];
input.readFully(patchBytes);
return new ClassPatch(name, sourceClassName, targetClassName, exists, inputChecksum, patchBytes);
}
示例7: readNBTTagCompound
import com.google.common.io.ByteArrayDataInput; //导入方法依赖的package包/类
/**
* Reads a compressed NBTTagCompound from the InputStream
*/
public static NBTTagCompound readNBTTagCompound(ByteArrayDataInput par0DataInputStream) throws IOException {
short short1 = par0DataInputStream.readShort();
if (short1 < 0) {
return null;
} else {
byte[] abyte = new byte[short1];
par0DataInputStream.readFully(abyte);
return CompressedStreamTools.decompress(abyte);
}
}
示例8: readNBTTagCompound
import com.google.common.io.ByteArrayDataInput; //导入方法依赖的package包/类
public static NBTTagCompound readNBTTagCompound(ByteArrayDataInput stream) throws IOException
{
int id = stream.readInt();
if (id < 0)
{
return null;
}
else
{
byte[] abyte = new byte[id];
stream.readFully(abyte);
return CompressedStreamTools.decompress(abyte);
}
}
示例9: decode
import com.google.common.io.ByteArrayDataInput; //导入方法依赖的package包/类
@Override
public VersionedData<byte[], Integer> decode(byte[] encoded) {
ByteArrayDataInput in = ByteStreams.newDataInput(encoded);
int version = in.readInt();
byte[] data = new byte[encoded.length - 4];
in.readFully(data);
return new VersionedData<byte[], Integer>(data, version);
}
示例10: bytesToType
import com.google.common.io.ByteArrayDataInput; //导入方法依赖的package包/类
@Override
protected BigDecimal bytesToType(byte[] p) {
ByteArrayDataInput in = ByteStreams.newDataInput(p);
int scale = in.readInt();
byte[] buff = new byte[p.length - 4];
in.readFully(buff);
BigInteger bi = new BigInteger(buff);
return new BigDecimal(bi, scale);
}
示例11: readPatch
import com.google.common.io.ByteArrayDataInput; //导入方法依赖的package包/类
private ClassPatch readPatch(JarEntry patchEntry, JarInputStream jis)
{
FMLRelaunchLog.finest("Reading patch data from %s", patchEntry.getName());
ByteArrayDataInput input;
try
{
input = ByteStreams.newDataInput(ByteStreams.toByteArray(jis));
}
catch (IOException e)
{
FMLRelaunchLog.log(Level.WARNING, e, "Unable to read binpatch file %s - ignoring", patchEntry.getName());
return null;
}
String name = input.readUTF();
String sourceClassName = input.readUTF();
String targetClassName = input.readUTF();
boolean exists = input.readBoolean();
int inputChecksum = 0;
if (exists)
{
inputChecksum = input.readInt();
}
int patchLength = input.readInt();
byte[] patchBytes = new byte[patchLength];
input.readFully(patchBytes);
return new ClassPatch(name, sourceClassName, targetClassName, exists, inputChecksum, patchBytes);
}
示例12: consumePart
import com.google.common.io.ByteArrayDataInput; //导入方法依赖的package包/类
private ForgePacket consumePart(INetworkManager network, byte[] data)
{
if (partTracker == null)
{
partTracker = new MapMaker().weakKeys().weakValues().makeMap();
}
if (!partTracker.containsKey(network))
{
partTracker.put(network, make());
}
ForgePacket pkt = partTracker.get(network);
ByteArrayDataInput bdi = ByteStreams.newDataInput(data);
int chunkIdx = UnsignedBytes.toInt(bdi.readByte());
int chunkTotal = UnsignedBytes.toInt(bdi.readByte());
int chunkLength = bdi.readInt();
if (pkt.partials == null)
{
pkt.partials = new byte[chunkTotal][];
}
pkt.partials[chunkIdx] = new byte[chunkLength];
bdi.readFully(pkt.partials[chunkIdx]);
for (int i = 0; i < pkt.partials.length; i++)
{
if (pkt.partials[i] == null)
{
return null;
}
}
return pkt;
}
示例13: load
import com.google.common.io.ByteArrayDataInput; //导入方法依赖的package包/类
@Override
public void load(NBTTagCompound nbt) {
if (node != null)
node.load(nbt);
tier = nbt.getInteger("tier")+1;
monitorAddress = nbt.getString("monitor");
if (monitorAddress.length() == 0)
monitorAddress = null;
init();
if (romGX != null) {
romGX.load(nbt.getCompoundTag("oc:romnode"));
}
NBTTagList stateReloadPackets = nbt.getTagList("state", 10);
if (stateReloadPackets != null)
{
for (int i=0; i<stateReloadPackets.tagCount(); i++)
{
NBTTagCompound pkt = stateReloadPackets.getCompoundTagAt(i);
IGX.DataType type = IGX.DataType.values()[pkt.getInteger("type")];
byte[] data = nbt.getByteArray("data");
ByteArrayDataInput dat = ByteStreams.newDataInput(data);
switch (type)
{
case FIFO:
gx.uploadFIFO(dat,data);
break;
case TEXTURE:
int id = dat.readShort();
int fmt = dat.readByte();
int size = dat.readInt();
byte[] texdata = new byte[size];
dat.readFully(texdata);
gx.uploadTexture((short) id, new ByteArrayInputStream(texdata), (byte) fmt);
break;
}
}
}
}