Writing Text to a Socket - Java Network

Java examples for Network:Socket

Description

Writing Text to a Socket

Demo Code

import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.net.Socket;

public class Main {

  public static void main(String[] argv) {
    try {/* w  w  w.  ja v  a 2  s .c o  m*/
      Socket socket = null;
      BufferedWriter wr = new BufferedWriter(new OutputStreamWriter(
          socket.getOutputStream()));
      wr.write("aString");
      wr.flush();
    } catch (IOException e) {
    }
  }
}

Related Tutorials