Exemplo n.º 1
0
 public static void unCompressLzo(String input, String output, Configuration conf) {
   LzopCodec lzo = null;
   InputStream is = null;
   InputStreamReader isr = null;
   BufferedReader reader = null;
   String line = null;
   BufferedWriter bw = null;
   try {
     bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(output)));
     lzo = new LzopCodec();
     lzo.setConf(conf);
     is = lzo.createInputStream(new FileInputStream(input));
     isr = new InputStreamReader(is);
     reader = new BufferedReader(isr);
     while ((line = reader.readLine()) != null) {
       bw.write(line);
       bw.newLine();
     }
   } catch (FileNotFoundException e) {
     e.printStackTrace();
   } catch (IOException e) {
     e.printStackTrace();
   } finally {
     try {
       if (null != reader) reader.close();
       if (null != isr) isr.close();
       if (null != is) is.close();
       if (null != bw) bw.close();
     } catch (IOException e) {
       e.printStackTrace();
     }
   }
 }
Exemplo n.º 2
0
  public static List<String> readLzoFile(String lzoFilePath, Configuration conf) {
    LzopCodec lzo = null;
    InputStream is = null;
    InputStreamReader isr = null;
    BufferedReader reader = null;
    List<String> result = null;
    String line = null;

    try {
      lzo = new LzopCodec();
      lzo.setConf(conf);
      is = lzo.createInputStream(new FileInputStream(lzoFilePath));
      isr = new InputStreamReader(is);
      reader = new BufferedReader(isr);
      result = new ArrayList<String>();
      while ((line = reader.readLine()) != null) {
        result.add(line);
      }

    } catch (FileNotFoundException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    } finally {
      try {
        if (reader != null) {
          reader.close();
        }
        if (isr != null) {
          isr.close();
        }
        if (is != null) {
          is.close();
        }
      } catch (IOException e) {
        e.printStackTrace();
      }
    }
    return result;
  }