NullPointerException while accessing Servlet Response from Java
<p>I am calling  a Java servlet from my Java file. The servlet file has SOP to return a JSON string. Now I wish to use that string in my Java code and then parse it into XML.</p>

<p>My code is as follows: </p>

<pre><code>URL urlS = new URL (servletURL);
URLConnection urlc;
urlc = urlS.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(urlc.getInputStream()));

String inputLine;
while ((inputLine = in.readLine()) != null)
    System.out.println("We got JSON Buddy: "+inputLine);
JSONObject js = new JSONObject(inputLine);
System.out.println("We got json object js: "+js.toString());
in.close();
</code></pre>

<p>The problem is my SOP for Java code is :</p>

<pre><code>12-02 10:30:12.254: I/System.out(24169): We got JSON Buddy: {"movies": { "total": 19, "movie":[{"cover":"http://content9.flixster.com/movie/11/16/04/11160419_pro.jpg","tile":"A Very Harold &amp; Kumar 3D Christmas","MovieDuration":"(R , 1 hr. 29 min.)","showtime":"                                                                                                                                                                                                                                                                                                                                                                                                                                                                           9:35 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         12:00 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                ","theatre":"Rave Motion Pictures 18 + IMAX","url":"http://www.flixster.com/movie/a-very-harold-and-kumar-christmas"},{"cover":"http://content6.flixster.com/movie/11/16/12/11161272_pro.jpg","tile":"Arthur Christmas 3D","MovieDuration":"(PG , 1 hr. 37 min.)","showtime":"                                                                                                                                                                                                                                                                                                                                                                                                                                                                           12:15 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         3:00 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         5:35 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                ","theatre":"Rave Motion Pictures 18 + IMAX","url":"http://www.flixster.com/movie/arthur-christ
12-02 10:30:12.266: I/System.out(24169): Exception: java.lang.NullPointerException
</code></pre>

<p>The issue is I am not getting the complete output in the inputLine, and the other problem is the NullPointerException. I am not able to figure out why this is happening.</p>
