Пример #1
0
 public void openFileTest(String buffer) {
   DBInsert db = new DBInsert("hhscyber:tweets_test");
   this.parseJSON(buffer);
   db.setDataArray(tweets);
   db.doFlush();
   db.close();
   tweets.clear();
 }
Пример #2
0
  public void openDir(File[] files) {
    DBInsert db = new DBInsert("hhscyber:tweets_test");
    for (File file : files) {
      if (file.isDirectory()) {
        System.out.println("Directory: " + file.getName());
        this.openDir(file.listFiles());
      } else {
        if (!this.isFileValid(file.getName())) {
          continue;
        }

        FileInputStream fis = null;
        try {
          fis = new FileInputStream(file);

          int content;
          String text = "";
          while ((content = fis.read()) != -1) {
            // convert to char and display it
            String tmp = Character.toString((char) content);
            text = text + tmp;
          }
          this.parseJSON(text);
        } catch (IOException e) {
        } finally {
          try {
            if (fis != null) {
              fis.close();
            }
          } catch (IOException ex) {
          }
        }
      }
    }
    db.setDataArray(tweets);
    db.doFlush();
    db.close();
    tweets.clear();
  }