Skip to content

Instantly share code, notes, and snippets.

@jaxbot
Created October 23, 2015 23:18
Show Gist options
  • Save jaxbot/78d90a4b6db89e438c5d to your computer and use it in GitHub Desktop.
Save jaxbot/78d90a4b6db89e438c5d to your computer and use it in GitHub Desktop.
private String getHTTPString(String url, CookieStore jar) {
try {
DefaultHttpClient httpclient = new DefaultHttpClient();
HttpGet httpget = new HttpGet(url);
httpget.setHeader("User-Agent", UA);
httpclient.setCookieStore(jar);
HttpResponse response = httpclient.execute(httpget);
InputStream inputStream = response.getEntity().getContent();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
String line;
String result = "";
while ((line = bufferedReader.readLine()) != null) {
result += line;
}
inputStream.close();
return result;
} catch (Exception e) {
System.out.println(e);
}
return "";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment