Package org.jboss.fresh.shell.commands

Source Code of org.jboss.fresh.shell.commands.Bzip2Exe

package org.jboss.fresh.shell.commands;

import org.jboss.fresh.io.BufferObjectReader;
import org.jboss.fresh.io.BufferOutputStream;
import org.jboss.fresh.io.BufferWriter;
import org.jboss.fresh.shell.AbstractExecutable;

import org.apache.commons.compress.bzip2.CBZip2OutputStream;

import java.io.ObjectOutputStream;
import java.io.PrintWriter;

/**
* Please type in some text here.
*
* @author boky
* @version $Revision: 1860 $
* @created 2004.7.22, 9:45:31
* @date $Date: 2004-09-16 13:53:57 +0200 (čet, 16 sep 2004) $
* @source $Source$
* @modified $Author: boky $
*/
public class Bzip2Exe extends AbstractExecutable {
  public static final String VERSION = "$Header$";

  protected void process(String exepath, String[] args) throws Exception {
    BufferObjectReader in = new BufferObjectReader(getStdIn());
    BufferOutputStream out = getStdOutStream();
    CBZip2OutputStream bout = new CBZip2OutputStream(out);
    ObjectOutputStream oout = new ObjectOutputStream(bout);
    Object obj;
    try {
      while( !in.isFinished() ) {
        obj = in.readObject();
        oout.writeObject(obj);
        oout.flush();
        bout.flush();
        out.flush();
      }
      in.close();
    } catch (Exception e) {
      if(canThrowEx()) {
        throw e;
      } else {
        org.jboss.fresh.io.BufferWriter bw = new BufferWriter(getStdOut());
        PrintWriter tOut = new PrintWriter(bw);
        tOut.write(e.toString());
      }
    }
    oout.close();
    bout.close();
    out.close();
  }

}
TOP

Related Classes of org.jboss.fresh.shell.commands.Bzip2Exe

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.