I suspect the problem is that you're not getting a good connection.
if(response == HttpURLConnection.HTTP_OK)
{
in = httpConn.getInputStream();
}
At this point in the code you're setting the input stream, but if the result is not HTTP_OK, you're going to return null
, and you're not handling that possibility correctly, neither in OpenHttpConnection()
nor in wolframAnswer()
where you call it. It seems something in your connection setup code is not correctly connecting, and thus your input stream is null
and crashing when you try to parse it with the DocumentBuilder.