Here you can find the source of get(String url)
public static String get(String url) throws IOException
//package com.java2s; /**/*w w w .j a va2s. c om*/ * Copyright (c) 2010-2016 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; public class Main { private static final String USER_AGENT = "Java"; public static String get(String url) throws IOException { URL obj = new URL(url); HttpURLConnection con = (HttpURLConnection) obj.openConnection(); con.setRequestMethod("GET"); con.setRequestProperty("User-Agent", USER_AGENT); int responseCode = con.getResponseCode(); if (responseCode != 200) { throw new IOException("Response Code: " + responseCode); } BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())); try { StringBuilder response = new StringBuilder(); String line; while ((line = in.readLine()) != null) { response.append(line); } return response.toString(); } finally { in.close(); } } }