Beispiel #1
0
 private InputStream inputStream(InputStream in) throws IOException {
   try {
     return csfType == null
         ? in
         : new CompressorStreamFactory().createCompressorInputStream(csfType, in);
   } catch (CompressorException e) {
     IOException ioe = new IOException(e.getMessage());
     ioe.initCause(e);
     throw ioe;
   }
 }
Beispiel #2
0
 private OutputStream outputStream(OutputStream os) throws IOException {
   try {
     return csfType == null
         ? os
         : new CompressorStreamFactory().createCompressorOutputStream(csfType, os);
   } catch (CompressorException e) {
     IOException ioe = new IOException(e.getMessage());
     ioe.initCause(e);
     throw ioe;
   }
 }
  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;
  }