public JSONObject instantiateJsonObject ( InputStream in ) throws IOException , JSONException { BufferedReader reader = new BufferedReader ( new InputStreamReader ( in ) ) ; StringBuffer contents = new StringBuffer ( ) ; String text = null ; while ( ( text = reader . readLine ( ) ) != null ) { contents . append ( text ) . append ( System . getProperty ( "line.separator" ) ) ; } in . close ( ) ; JSONObject json = new JSONObject ( contents . toString ( ) ) ; return json ; }
Given an input stream read in the contents of the file and instantiate a JSON object if it exists .