public class ServerTest {
public static void main(String[] args) throws
Exception {
StringBuffer buf = new StringBuffer();
buf.append("<event>\n");// Start-Tag
buf.append(String.format("<address>%s</address>\n", "123test"));// Code
buf.append(String.format("<message>%s</message>\n", "Hello World"));// Text
buf.append("</event>");// End-Tag
try {
Socket socket = new Socket("
localhost", 5555);// 5555 = Default-Port
OutputStream
os = socket.getOutputStream();
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(
os, "UTF-8"));
bw.write(buf.toString());
bw.flush();
bw.close();
os.close();
} catch (
Exception e) {
e.printStackTrace();
}
}
}