source: other-projects/hathitrust/wcsa/extracted-features-solr/trunk/solr-ingest/src/main/java/org/hathitrust/extractedfeatures/JSONClusterFileIO.java@ 31045

Last change on this file since 31045 was 31045, checked in by davidb, 7 years ago

More careful treatment of what to do when a JSON file isn't there

  • Property svn:executable set to *
File size: 679 bytes
Line 
1package org.hathitrust.extractedfeatures;
2
3import java.io.BufferedReader;
4
5import org.json.JSONObject;
6
7public class JSONClusterFileIO extends ClusterFileIO {
8
9 protected static JSONObject readJSONFile(String filename)
10 {
11 JSONObject json_obj = null;
12
13 try {
14 StringBuilder sb = new StringBuilder();
15
16 String str;
17 BufferedReader br = ClusterFileIO.getBufferedReaderForCompressedFile(filename);
18 while ((str = br.readLine()) != null) {
19 sb.append(str);
20 }
21
22 br.close();
23
24 json_obj = new JSONObject(sb.toString());
25 }
26 catch (Exception e) {
27 e.printStackTrace();
28 }
29
30 return json_obj;
31 }
32
33}
Note: See TracBrowser for help on using the repository browser.