Here you can find the source of sendGet(String url)
public static String sendGet(String url) throws Exception
//package com.java2s; /*// w w w.ja v a 2 s .co m * @(#)CommunicationHelper.java * * Copyright 2013 openmolecules.org, Inc. All Rights Reserved. * * NOTICE: All information contained herein is, and remains the property * of openmolecules.org. The intellectual and technical concepts contained * herein are proprietary to openmolecules.org. * Actelion Pharmaceuticals Ltd. is granted a non-exclusive, non-transferable * and timely unlimited usage license. * * @author Thomas Sander */ import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; public class Main { private static final String USER_AGENT = "Mozilla/5.0"; public static String sendGet(String url) throws Exception { HttpURLConnection con = (HttpURLConnection) new URL(url) .openConnection(); // optional default is GET con.setRequestMethod("GET"); //add request header con.setRequestProperty("User-Agent", USER_AGENT); // int responseCode = con.getResponseCode(); // 200 or 401 BufferedReader in = new BufferedReader(new InputStreamReader( con.getInputStream())); String inputLine; StringBuffer response = new StringBuffer(); while ((inputLine = in.readLine()) != null) response.append(inputLine); in.close(); return response.toString(); } }