title: Read JSON file without using external libraries (update using only org.json)
body: <p>i have an assignement where i have to read a json file containing elections information  and save the data i get. The problem is i can't use any external libraries like simple json etc. The proffessor sugested i did something like this: </p>
  
  <pre><code>FileInputStream fin = new FileInputStream(new File(filename));
  JSONTokener tokener = new JSONTokener(fin);
  JSONObject elections = new JSONObject(tokener);
  
  JSONArray candidates = elections.getJSONArray("candidates"); JSONArray
  ballots = elections.getJSONArray("ballots");
  </code></pre>
  
  <p>Then i could access my candidates with </p>
  
  <pre><code>candidates.getString(i)
  </code></pre>
  
  <p>And my ballots with </p>
  
  <pre><code>JSONArray ballot = ballots.getJSONArray(i)
  </code></pre>
  
  <p>But when i run the code i get the following exception :</p>
  
  <pre><code>org.json.JSONException: A JSONObject text must begin with '{' at 6 [character 1 line 6]
  at org.json.JSONTokener.syntaxError(JSONTokener.java:433)
  at org.json.JSONObject.&lt;init&gt;(JSONObject.java:194)
  at Schulze.main(Schulze.java:17)
  </code></pre>
  
  <p>The exception comes from this line of code : </p>
  
  <pre><code>JSONObject elections = new JSONObject(tokener);
  </code></pre>
  
  <p>The json files content is something like this : </p>
  
  <blockquote>
    <p>{    "candidates": [
           "a", "b", "c", "d"    ],    "ballots": [
           [0, 2, 3, 1],
           [0, 2, 3, 1],
           [0, 2, 3, 1],
           [0, 2, 3, 1],
           [0, 2, 3, 1],
           [0, 2, 3, 1],</p>
  
  <pre><code>   [1, 0, 3, 2],
     [1, 0, 3, 2],
     [1, 0, 3, 2],
     [1, 0, 3, 2],
  
     [2, 3, 1, 0],
     [2, 3, 1, 0], 
     [2, 3, 1, 0],
  
     [3, 1, 0, 2],
     [3, 1, 0, 2], 
     [3, 1, 0, 2],
     [3, 1, 0, 2],        
  
     [3, 2, 1, 0],
     [3, 2, 1, 0],        
     [3, 2, 1, 0],
     [3, 2, 1, 0]    ] }
  </code></pre>
  </blockquote>
  
  <p>Any ideas on what might be the problem here?</p>