Guava ByteArrayDataOutput - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Guava ByteArrayDataOutput class.

This code example shows how to use the following methods:writeBoolean
    } 
 
    @Override 
    public void encode(ByteArrayDataOutput output)
    { 
        output.writeBoolean(add);
        loc.writeToData(output, true);
    } 
 
    @Override 
    public void decode(ByteArrayDataInput input)
    { 
        add = input.readBoolean();
        loc = BlockLocation.readFromData(input, true, 0);
    } 
 
    @Override 
    public void actionClient(World world, EntityPlayer player)
    { 
        if (add) // add
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:toByteArray, writeByte
	} 
 
	public final Packet makePacket() 
	{ 
		ByteArrayDataOutput out = ByteStreams.newDataOutput();
		out.writeByte(getPacketId());
		write(out);
		return PacketDispatcher.getPacket(CHANNEL, out.toByteArray());
	} 
 
	public abstract void write(ByteArrayDataOutput out);
 
	public abstract void read(ByteArrayDataInput in) throws ProtocolException;
 
	public abstract void execute(EntityPlayer player, Side side) throws ProtocolException;
} 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:toByteArray
  @SuppressWarnings("deprecation") 
  private void verifyDecodingSupportsV1(TransactionEdit edit) throws IOException {
    TransactionEdit.TransactionEditCodecV1 v1Codec = new TransactionEdit.TransactionEditCodecV1();
    // encoding with codec of v1 
    ByteArrayDataOutput out = ByteStreams.newDataOutput();
    v1Codec.encode(edit, out);
 
    // decoding 
    TransactionEdit decodedEdit = new TransactionEdit();
    DataInput in = ByteStreams.newDataInput(out.toByteArray());
    decodedEdit.readFields(in);
 
    Assert.assertEquals(edit, decodedEdit);
  } 
} 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:toByteArray
    } 
 
    public void testLong(long l) throws IOException {
        final VarULongSerializer serializer = new VarULongSerializer();
        final ByteArrayDataOutput out = ByteStreams.newDataOutput();
        serializer.write(l, out);
        assertEquals(l, serializer.read(ByteStreams.newDataInput(out.toByteArray())).longValue());
    } 
 
    public void testInt(int i) throws IOException {
        final VarULongSerializer serializer = new VarULongSerializer();
        final ByteArrayDataOutput out = ByteStreams.newDataOutput();
        out.writeInt(i);
        assertEquals(i, serializer.read(ByteStreams.newDataInput(out.toByteArray())).longValue());
    } 
} 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:toByteArray
import java.io.IOException;
 
public class JournalUtil { 
  public static byte[] locationToBytes(Location location) throws IOException {
    ByteArrayDataOutput dos = ByteStreams.newDataOutput();
    location.writeExternal(dos);
    return dos.toByteArray();
  } 
 
  public static Journal createJournal(String dirPath, int fileSize, int writeBatchSize) {
    Journal journal = new Journal();
    File directory = new File(dirPath);
    //noinspection ResultOfMethodCallIgnored 
    directory.mkdirs();
    journal.setDirectory(directory);
    journal.setMaxFileLength(fileSize);
    journal.setMaxWriteBatchSize(writeBatchSize);
 
    try { 
      journal.open();
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:toByteArray
    public void testSerialization() throws Exception {
        final Broker broker = new Broker("127.0.0.1", 9092, 1);
        final Partition partition = new Partition("topic_name", 0, broker);
        final KafkaInputSplit split = new KafkaInputSplit(partition, 0, 10l, false);
        final ByteArrayDataOutput out = ByteStreams.newDataOutput();
        split.write(out);
 
        final KafkaInputSplit actual = new KafkaInputSplit();
        actual.readFields(ByteStreams.newDataInput(out.toByteArray()));
 
        assertEquals(split, actual);
    } 
} 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:write, writeShort
    
    byte[] var2;
    try 
      { 
      var2 = CompressedStreamTools.compress(par0NBTTagCompound);
      data.writeShort((short)var2.length);
      data.write(var2);
      }  
    catch (IOException e)
      { 
      Config.logError("Severe error writing NBTTagCompound to dataStream");
      e.printStackTrace();
      }  
    } 
  } 
 
/** 
 * Reads a compressed NBTTagCompound from the InputStream 
 */ 
public static NBTTagCompound readNBTTagCompound(ByteArrayDataInput data)
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:toByteArray
  } 
 
  private static byte[] toBytes(ConsumerConfig consumerConfig) throws IOException {
    ByteArrayDataOutput dataOutput = ByteStreams.newDataOutput();
    write(dataOutput, consumerConfig);
    return dataOutput.toByteArray();
  } 
 
  public static void write(DataOutput dataOutput, ConsumerConfig consumerConfig) throws IOException {
    dataOutput.writeLong(consumerConfig.getGroupId());
    dataOutput.writeInt(consumerConfig.getGroupSize());
    dataOutput.writeInt(consumerConfig.getInstanceId());
    WritableUtils.writeEnum(dataOutput, consumerConfig.getDequeueStrategy());
    WritableUtils.writeString(dataOutput, consumerConfig.getHashKey());
  } 
 
  private static ConsumerConfig bytesToConsumerConfig(byte[] bytes) throws IOException {
    ByteArrayDataInput dataInput = ByteStreams.newDataInput(bytes);
    return readConsumerConfig(dataInput);
  } 
3
CodeRank
Experience pair programming with AI  Get Codota for Java
See Code Examples for Guava ByteArrayDataOutput Methods: