Example usage for com.google.common.io ByteArrayDataOutput toByteArray

List of usage examples for com.google.common.io ByteArrayDataOutput toByteArray

Introduction

In this page you can find the example usage for com.google.common.io ByteArrayDataOutput toByteArray.

Prototype

byte[] toByteArray();

Source Link

Document

Returns the contents that have been written to this instance, as a byte array.

Usage

From source file:com.facebook.presto.raptor.RaptorColumnIdentity.java

@Override
public byte[] serialize() {
    ByteArrayDataOutput output = newDataOutput(SERIALIZED_SIZE);
    output.write(CURRENT_VERSION);//from   w w  w  .ja v a2  s .  co m
    output.writeLong(columnId);
    return output.toByteArray();
}

From source file:com.facebook.presto.raptor.RaptorTableIdentity.java

@Override
public byte[] serialize() {
    ByteArrayDataOutput output = newDataOutput(SERIALIZED_SIZE);
    output.write(CURRENT_VERSION);//w w  w.ja va 2s . c  o m
    output.writeLong(tableId);
    return output.toByteArray();
}

From source file:me.lucko.luckperms.bukkit.messaging.BungeeMessagingService.java

@Override
protected void sendMessage(String channel, String message) {
    new BukkitRunnable() {
        @Override/*  ww w .j  a  v  a  2  s.c  o  m*/
        public void run() {
            Collection<? extends Player> players = plugin.getServer().getOnlinePlayers();
            if (players.isEmpty()) {
                return;
            }

            Player p = Iterables.getFirst(players, null);

            ByteArrayDataOutput out = ByteStreams.newDataOutput();
            out.writeUTF(message);

            byte[] data = out.toByteArray();

            p.sendPluginMessage(plugin, channel, data);
            cancel();
        }
    }.runTaskTimer(plugin, 1L, 100L);
}

From source file:de.bl4ckskull666.afkbukkit.listeners.PlayerJoin.java

@EventHandler(priority = EventPriority.HIGH)
public void onPlayerJoin(PlayerJoinEvent e) {
    AFKBukkit.setHiddenPlayers(e.getPlayer());
    if (AFKBukkit.getPlugin().getConfig().getBoolean("use-bungeecord-config", false) && !_firstJoined) {
        AFKBukkit.debugMe("Request Configuration");
        ByteArrayDataOutput out = ByteStreams.newDataOutput();
        out.writeUTF("AFKB");
        out.writeUTF("Config");
        e.getPlayer().sendPluginMessage(AFKBukkit.getPlugin(), "BungeeCord", out.toByteArray());
        _firstJoined = true;/*  ww  w . j  a v  a 2s. c  o m*/
    }
}

From source file:me.lucko.luckperms.bungee.messaging.BungeeMessenger.java

@Override
public void sendOutgoingMessage(@Nonnull OutgoingMessage outgoingMessage) {
    ByteArrayDataOutput out = ByteStreams.newDataOutput();
    out.writeUTF(outgoingMessage.asEncodedString());

    byte[] data = out.toByteArray();

    for (ServerInfo server : this.plugin.getBootstrap().getProxy().getServers().values()) {
        server.sendData(CHANNEL, data, true);
    }/*from www. ja v  a2 s .  c om*/
}

From source file:nxminetilities.network.MinetilitiesPacket.java

public final Packet makePacket() {
    ByteArrayDataOutput out = ByteStreams.newDataOutput();
    out.writeByte(getPacketId());/*from ww  w  .  j  a v a 2s. c o m*/
    write(out);
    return PacketDispatcher.getPacket(CHANNEL, out.toByteArray());
}

From source file:com.google.devrel.gmscore.tools.apk.arsc.ResourceFile.java

@Override
public byte[] toByteArray(boolean shrink) throws IOException {
    ByteArrayDataOutput output = ByteStreams.newDataOutput();
    for (Chunk chunk : chunks) {
        output.write(chunk.toByteArray(shrink));
    }/*from   ww  w .j a  v a  2  s.  c  o m*/
    return output.toByteArray();
}

From source file:org.apache.eagle.alert.engine.serialization.impl.PartitionedEventSerializerImpl.java

@Override
public byte[] serialize(PartitionedEvent entity) throws IOException {
    ByteArrayDataOutput dataOutput = ByteStreams.newDataOutput();
    this.serialize(entity, dataOutput);
    return compress ? CompressionUtils.compress(dataOutput.toByteArray()) : dataOutput.toByteArray();
}

From source file:de.mineformers.robots.network.packet.PacketBase.java

public final Packet makePacket() {
    ByteArrayDataOutput out = ByteStreams.newDataOutput();
    out.writeByte(getPacketId());/*from   w w w . j  a  v a  2  s.  c om*/
    write(out);
    return PacketDispatcher.getPacket(Reference.CHANNEL_NAME, out.toByteArray());
}

From source file:de.bl4ckskull666.mu1ti1ingu41.listener.PostLogin.java

private void sendPlayerLanguageToServer(ServerInfo si, UUID uuid, String language) {
    ByteArrayDataOutput out = ByteStreams.newDataOutput();
    out.writeUTF("player");
    out.writeUTF(uuid.toString());/* w  w  w . j  a v a2 s. c  o  m*/
    out.writeUTF(language);
    si.sendData("Mu1ti1ingu41", out.toByteArray());
}