Code example for PrintWriter

Methods: flushwrite

0
	 
	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();
		printer.write(httpPingPacket);
		printer.flush();
		 
		//final byte[] buffer = new byte[1]; 
		final String line = in.readLine();
		RTT = System.currentTimeMillis() - start;
		 
		return (int)RTT;
Stop searching for code, let great code find you!  Add Codota to your java IDE