Package org.jboss.fresh.shell.commands

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

package org.jboss.fresh.shell.commands;

import org.jboss.fresh.shell.AbstractExecutable;
import org.jboss.fresh.io.BufferObjectWriter;
import org.jboss.fresh.io.BufferInputStream;
import org.jboss.fresh.io.BufferWriter;

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

import java.io.ObjectInputStream;
import java.io.PrintWriter;

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

  protected void process(String exepath, String[] args) throws Exception {
    BufferObjectWriter out = new BufferObjectWriter(getStdOut());
    BufferInputStream in = getStdInStream();
    CBZip2InputStream bin = new CBZip2InputStream(in);
    ObjectInputStream oin = new ObjectInputStream(bin);
    Object obj;
    try {
      boolean eof = false;
      while( !eof ) {
        try {
          obj = oin.readObject();
          out.writeObject(obj);
        } catch (java.io.OptionalDataException ode) {
          if(ode.eof) {
            eof = true;
            oin.close();
            bin.close();
            in.close();
          } else {
            throw ode;
          }
        }
      }
    } 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());
      }
    }
    out.close();
  }
}
TOP

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

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.