package com.complet;

import java.io.IOException;
import java.net.*;

public class ServerResponse {

	public static void response(URL url) throws IOException {

		HttpURLConnection connection = (HttpURLConnection) url.openConnection();

		try {

			connection.connect();

		} catch (Exception exp) {

		    System.err.println(exp.getMessage());

		}
	}

}
package com.complet;

import java.io.IOException;
import java.net.*;

public class ServerResponse {

	public static String response(URL url) throws IOException {

		HttpURLConnection connection = (HttpURLConnection) url.openConnection();

		try {

			connection.connect();
			String response = connection.getResponseMessage();
			connection.disconnect();
			return response;

		} catch (Exception exp) {

		    return exp.getMessage();

		}
	}

}
return a string which contains the HTTP response message or an error message- close connection