Print stream server
import java.io.PrintStream; import java.net.ServerSocket; import java.net.Socket; public class Main { public static void main(String args[]) throws Exception { ServerSocket ssock = new ServerSocket(1234); Socket sock = ssock.accept(); ssock.close(); PrintStream pstream = new PrintStream(sock.getOutputStream()); for (int i = 100; i >= 0; i--) { pstream.println(i); } pstream.close(); sock.close(); } }