Ejemplo n.º 1
0
 public static void main(String[] args)
     throws IOException, IllegalAccessException, InstantiationException {
   ProximityHashingIndexor indexor = new ProximityHashingIndexor();
   for (int i = 0; i < args.length; i++) {
     String arg = args[i];
     if (arg.startsWith("-i") || arg.startsWith("--input-file")) {
       // infile ...
       if ((i + 1) < args.length) indexor.addInputFile(new File(args[i + 1]));
       else printHelp();
     } else if (arg.startsWith("-l") || arg.startsWith("--index")) {
       // index
       if ((i + 1) < args.length) indexor.setIndexPath(args[i + 1]);
       else printHelp();
     } else if (arg.startsWith("-h")) {
       // help
       printHelp();
     } else if (arg.startsWith("-s")) {
       // silent ...
       verbose = false;
     } else if (arg.startsWith("-c")) {
       // list of input files within a file.
       if ((i + 1) < args.length) {
         BufferedReader br = new BufferedReader(new FileReader(new File(args[i + 1])));
         String file;
         while ((file = br.readLine()) != null) {
           if (file.trim().length() > 2) {
             File f = new File(file);
             if (f.exists()) indexor.addInputFile(f);
             else System.err.println("Did not find file " + f.getCanonicalPath());
           }
         }
       } else printHelp();
     }
   }
   // check if there is an infile, an outfile and some features to extract.
   if (!indexor.isConfigured()) {
     printHelp();
   } else {
     indexor.run();
   }
 }
Ejemplo n.º 2
0
  public JSONArray readJsonFile() {

    BufferedReader br = null;
    JSONParser parser = new JSONParser();
    JSONArray array = new JSONArray();
    try {

      String sCurrentLine;
      br = getBufferedReaderForCompressedFile(jsonFilePath);
      //            br = new BufferedReader(new FileReader(jsonFilePath));

      while ((sCurrentLine = br.readLine()) != null) {
        //                System.out.println("Record:\t" + sCurrentLine);

        Object obj;
        try {
          obj = parser.parse(sCurrentLine);
          JSONObject jsonObject = (JSONObject) obj;
          array.add(jsonObject);

        } catch (ParseException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
      }

    } catch (IOException e) {
      e.printStackTrace();
    } catch (CompressorException ex) {
      ex.printStackTrace();
    } finally {
      try {
        if (br != null) br.close();
      } catch (IOException ex) {
        ex.printStackTrace();
      }
    }
    return array;
  }