Here you can find the source of get(URL url)
public static String get(URL url) throws IOException
//package com.java2s; /*//ww w. ja v a2 s. c o m * Copyright ? 2014 - 2016 | Wurst-Imperium | All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; public class Main { public static String get(URL url) throws IOException { HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("GET"); BufferedReader input = new BufferedReader(new InputStreamReader(connection.getInputStream())); StringBuilder buffer = new StringBuilder(); for (String line; (line = input.readLine()) != null;) { buffer.append(line); buffer.append("\n"); } input.close(); return buffer.toString(); } }