I am trying to read a JSON from a web page and store it as a string, however when debugging it keeps failing in the try statement at line:
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
public String networkRequest() throws IOException {
URL url = new URL("https://graph.facebook.com/me");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
try
{
InputStream inputStream = url.openStream();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
StringBuilder stringBuilder = new StringBuilder();
int cp;
while ((cp = bufferedReader.read()) != -1)
{
stringBuilder.append((char) cp);
}
return stringBuilder.toString();
}
catch(Exception ex)
{
return "nothing";
}
}
In which because of the fail reaches the catch and returns "nothing", does anyone understand what I am doing wrong?
BTW: My network is perfectly fine!