Example usage for java.io DataOutputStream writeUTF

List of usage examples for java.io DataOutputStream writeUTF

Introduction

In this page you can find the example usage for java.io DataOutputStream writeUTF.

Prototype

public final void writeUTF(String str) throws IOException 

Source Link

Document

Writes a string to the underlying output stream using modified UTF-8 encoding in a machine-independent manner.

Usage

From source file:org.arkhamnetwork.arcade.commons.bungee.BungeecordHook.java

public static void sendPluginMessage(Player player, List<String> messages) throws IOException {
    Arcade.getInstance().log(//w  ww  .j  a  v a 2  s  .c  o  m
            ChatColor.DARK_GREEN + "[BungeeHook] Attempting to send plugin message " + messages.toString());

    ByteArrayOutputStream b = new ByteArrayOutputStream();
    DataOutputStream out = new DataOutputStream(b);

    for (String message : messages) {
        out.writeUTF(message);
    }

    player.sendPluginMessage(Arcade.getInstance(), "BungeeCord", b.toByteArray());
    out.flush();
}

From source file:Main.java

public static void writeNullableString(DataOutputStream out, String value) throws IOException {
    if (value != null) {
        out.write(1);/*www . j  a va2  s. co  m*/
        out.writeUTF(value);
    } else {
        out.write(0);
    }
}

From source file:com.koda.common.lcm.Tool.java

public static void toFile(String fn, Serializable obj) throws IOException {
    FileOutputStream fos = new FileOutputStream(fn);
    DataOutputStream dos = new DataOutputStream(fos);
    dos.writeUTF(doObject(obj));

}

From source file:Main.java

public static void secSet(Context context, String key, String val) {
    //long now = System.currentTimeMillis();
    FileOutputStream fos = null;//w  ww  .  j  a  va2  s . c  o  m
    try {
        DataOutputStream dos = new DataOutputStream(
                (fos = context.openFileOutput(key + ".mits", android.content.Context.MODE_PRIVATE)));
        dos.writeUTF(val);
    } catch (FileNotFoundException e1) {
        //e1.printStackTrace();
    } catch (IOException e1) {
        //e1.printStackTrace();
    } finally {
        if (fos != null)
            try {
                fos.close();
            } catch (IOException ignored) {
            }
    }
}

From source file:EZShare.SubscribeCommandConnection.java

public static boolean onKeyPressed(DataOutputStream sslOut, String string, JSONObject unsubscribJsonObject) {
    try {/* www . ja  v a  2  s.  c  om*/
        sslOut.writeUTF(unsubscribJsonObject.toString());
    } catch (IOException e) {
        e.printStackTrace();
    }
    return true;
}

From source file:com.fullhousedev.globalchat.bukkit.PluginMessageManager.java

public static void syncUsers(Plugin pl, String serverName) {
    try {//from   w w  w . jav a 2s  .  co m
        ByteArrayOutputStream customData = new ByteArrayOutputStream();
        DataOutputStream outCustom = new DataOutputStream(customData);
        outCustom.writeUTF(serverName);
        sendRawMessage("UserSync", "ALL", customData.toByteArray(), pl);
    } catch (IOException ex) {
        Logger.getLogger(GlobalChat.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:com.fullhousedev.globalchat.bukkit.PluginMessageManager.java

public static void userDisconnect(String username, Plugin pl) {
    try {/*  ww w  . j  a  va2  s.c o  m*/
        ByteArrayOutputStream customData = new ByteArrayOutputStream();
        DataOutputStream outCustom = new DataOutputStream(customData);
        outCustom.writeUTF(username);

        sendRawMessage("userdisconnect", "ALL", customData.toByteArray(), pl);
    } catch (IOException ex) {
        Logger.getLogger(GlobalChat.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:com.fullhousedev.globalchat.bukkit.PluginMessageManager.java

public static void userToggleMessage(String username, boolean on, Plugin pl) {
    try {//w  ww.  j a  v a2s . c  o  m
        ByteArrayOutputStream customData = new ByteArrayOutputStream();
        DataOutputStream outCustom = new DataOutputStream(customData);
        outCustom.writeUTF(username);
        outCustom.writeBoolean(on);

        sendRawMessage("togglemsg", "ALL", customData.toByteArray(), pl);
    } catch (IOException ex) {
        Logger.getLogger(GlobalChat.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:com.fullhousedev.globalchat.bukkit.PluginMessageManager.java

public static void userToggleSocialspy(String username, boolean on, Plugin pl) {
    try {/*from  ww w. j ava  2 s.  c  o m*/
        ByteArrayOutputStream customData = new ByteArrayOutputStream();
        DataOutputStream outCustom = new DataOutputStream(customData);
        outCustom.writeUTF(username);
        outCustom.writeBoolean(on);

        sendRawMessage("toggless", "ALL", customData.toByteArray(), pl);
    } catch (IOException ex) {
        Logger.getLogger(GlobalChat.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:com.fullhousedev.globalchat.bukkit.PluginMessageManager.java

public static void userConnect(String username, String server, Plugin pl) {
    try {//from   w w w.  ja  v a  2s. c  om
        ByteArrayOutputStream customData = new ByteArrayOutputStream();
        DataOutputStream outCustom = new DataOutputStream(customData);
        outCustom.writeUTF(username);
        outCustom.writeUTF(server);

        sendRawMessage("userconnect", "ALL", customData.toByteArray(), pl);
    } catch (IOException ex) {
        Logger.getLogger(GlobalChat.class.getName()).log(Level.SEVERE, null, ex);
    }
}