title: What’s the best way to load a JSONObject from a json text file?
body: <p>What would be the easiest way to load a file containing JSON into a JSONObject.</p>
  
  <p>At the moment I am using json-lib.</p>
  
  <p>This is what I have, but it throws an exception:</p>
  
  <pre><code>XMLSerializer xml = new XMLSerializer();
  JSON json = xml.readFromFile("samples/sample7.json”);     //line 507
  System.out.println(json.toString(2));
  </code></pre>
  
  <p>The output is:</p>
  
  <pre><code>Exception in thread "main" java.lang.NullPointerException
      at java.io.Reader.&lt;init&gt;(Reader.java:61)
      at java.io.InputStreamReader.&lt;init&gt;(InputStreamReader.java:55)
      at net.sf.json.xml.XMLSerializer.readFromStream(XMLSerializer.java:386)
      at net.sf.json.xml.XMLSerializer.readFromFile(XMLSerializer.java:370)
      at corebus.test.deprecated.TestMain.main(TestMain.java:507)
  </code></pre>