Create PrintWriter from BufferedWriter, OutputStreamWriter and Socket
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.InetAddress;
import java.net.Socket;
public class Main {
public static void main(String[] arges) throws Exception {
InetAddress addr = InetAddress.getByName(null);
Socket sk = new Socket(addr, 8888);
BufferedReader in = new BufferedReader(new InputStreamReader(sk.getInputStream()));
PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(sk.getOutputStream())), true);
out.println("asdf");
System.out.println(in.readLine());
}
}
Related examples in the same category