Try something like this:
CloseableHttpClient httpclient = HttpClients.createDefault();
String url = "http://api.search.yahoo.com/WebSearchService/V1/webSearch?appid=YahooDemo&query=umbrella&results=10";
HttpGet httpget = new HttpGet(url);
CloseableHttpResponse response = httpclient.execute(httpget);
try {
HttpEntity entity = response.getEntity();
InputStream is = entity.getContent();
//do stuff with is
} finally {
response.close();
}
I am unfamiliar with the Yahoo Finance API, but if the response is JSON and you are cool with using Jackson, you can do this with the InputStream
:
ObjectMapper mapper = new ObjectMapper();
Map<String, Object> jsonMap = mapper.readValue(inputStream, Map.class);