本文整理匯總了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;
}
}
}
}