當前位置: 首頁>>代碼示例>>Java>>正文


Java ByteArrayDataInput.readFully方法代碼示例

本文整理匯總了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.");
		}
	}
}
 
開發者ID:smessie,項目名稱:SkyWarsReloaded,代碼行數:21,代碼來源:SkyWarsReloaded.java

示例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);
}
 
開發者ID:nailed,項目名稱:nailed,代碼行數:20,代碼來源:BinPatchManager.java

示例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;
}
 
開發者ID:HATB0T,項目名稱:RuneCraftery,代碼行數:23,代碼來源:ModIdMapPacket.java

示例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);
}
 
開發者ID:lucko,項目名稱:helper,代碼行數:9,代碼來源:BungeeMessaging.java

示例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);
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:30,代碼來源:ClassPatchManager.java

示例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);
}
 
開發者ID:alexandrage,項目名稱:CauldronGit,代碼行數:29,代碼來源:ClassPatchManager.java

示例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);
    }
}
 
開發者ID:TheAwesomeGem,項目名稱:MineFantasy,代碼行數:16,代碼來源:BattlegearUtils.java

示例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);
    }
}
 
開發者ID:TheAwesomeGem,項目名稱:MineFantasy,代碼行數:16,代碼來源:PacketManagerMF.java

示例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);
}
 
開發者ID:agwlvssainokuni,項目名稱:sqlapp,代碼行數:9,代碼來源:DefaultVersionStrategy.java

示例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);
}
 
開發者ID:agwlvssainokuni,項目名稱:sqlapp,代碼行數:10,代碼來源:SecureBigDecimalEncoder.java

示例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);
}
 
開發者ID:HATB0T,項目名稱:RuneCraftery,代碼行數:29,代碼來源:ClassPatchManager.java

示例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;
}
 
開發者ID:HATB0T,項目名稱:RuneCraftery,代碼行數:36,代碼來源:ForgePacket.java

示例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;
       		}
       	}
       }
}
 
開發者ID:ds84182,項目名稱:OpenGX,代碼行數:40,代碼來源:ComponentGX.java


注:本文中的com.google.common.io.ByteArrayDataInput.readFully方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。