Code example for PrintWriter

Methods: flushwrite

	public static int HTTPPing(String host, int port) throws IOException {
		socket = new Socket(host, port);
		out = socket.getOutputStream();
		printer = new PrintWriter(out);
		in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
		long start;
		long RTT = 0;
		start = System.currentTimeMillis();
		//final byte[] buffer = new byte[1]; 
		final String line = in.readLine();
		RTT = System.currentTimeMillis() - start;
		return (int)RTT;
Connect your IDE to all the code out there  Get Codota for Java