Last change
on this file since 31272 was 31272, checked in by davidb, 7 years ago |
Use disk and memory to store main language RDD
|
-
Property svn:executable
set to
*
|
File size:
782 bytes
|
Rev | Line | |
---|
[30996] | 1 | package org.hathitrust.extractedfeatures;
|
---|
| 2 |
|
---|
| 3 | import java.io.BufferedReader;
|
---|
| 4 |
|
---|
| 5 | import org.json.JSONObject;
|
---|
| 6 |
|
---|
| 7 | public class JSONClusterFileIO extends ClusterFileIO {
|
---|
| 8 |
|
---|
| 9 | protected static JSONObject readJSONFile(String filename)
|
---|
| 10 | {
|
---|
[31045] | 11 | JSONObject json_obj = null;
|
---|
| 12 |
|
---|
[30996] | 13 | try {
|
---|
[31045] | 14 | StringBuilder sb = new StringBuilder();
|
---|
| 15 |
|
---|
[30996] | 16 | BufferedReader br = ClusterFileIO.getBufferedReaderForCompressedFile(filename);
|
---|
[31089] | 17 |
|
---|
| 18 | int cp;
|
---|
| 19 | while ((cp = br.read()) != -1) {
|
---|
| 20 | sb.append((char) cp);
|
---|
| 21 | }
|
---|
| 22 |
|
---|
| 23 | /*
|
---|
[31272] | 24 | String str;
|
---|
[30996] | 25 | while ((str = br.readLine()) != null) {
|
---|
| 26 | sb.append(str);
|
---|
| 27 | }
|
---|
[31089] | 28 | */
|
---|
[30996] | 29 |
|
---|
| 30 | br.close();
|
---|
[31045] | 31 |
|
---|
| 32 | json_obj = new JSONObject(sb.toString());
|
---|
[30996] | 33 | }
|
---|
| 34 | catch (Exception e) {
|
---|
| 35 | e.printStackTrace();
|
---|
| 36 | }
|
---|
| 37 |
|
---|
| 38 | return json_obj;
|
---|
| 39 | }
|
---|
| 40 |
|
---|
| 41 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.