Here is simple example where I fetch json from url and print out:
public static void main(String[] args) throws MalformedURLException, IOException {
String sURL = "your_url_goes_here";
URL url = new URL(sURL);
HttpURLConnection request = (HttpURLConnection) url.openConnection();
request.connect();
// Convert to a JSON object to print data
JsonParser jp = new JsonParser(); //from gson
//Convert the input stream to a json element
JsonElement root = jp.parse(new InputStreamReader((InputStream) request.getContent()));
JsonObject rootobj = root.getAsJsonObject(); //May be an array, may be an object.
System.out.println(rootobj.toString()); // json is printed
}