Package org.jboss.fresh.shell.commands

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

package org.jboss.fresh.shell.commands;

import java.io.ObjectOutputStream;
import java.io.PrintWriter;
import java.util.zip.GZIPOutputStream;
import org.jboss.fresh.shell.AbstractExecutable;
import org.jboss.fresh.io.BufferObjectReader;
import org.jboss.fresh.io.BufferOutputStream;
import org.jboss.fresh.io.BufferWriter;

/**
* @author boky
* @created 2003.9.1
* @version $Revision: 1860 $
* @modified $Author: boky $
*/
public class GzipExe extends AbstractExecutable {
  public static final String VERSION = "$Header: /store/cvsroot2/java/cp2/coderoot/cp2/cp2-systemshell/src/com/parsek/shell/commands/GzipExe.java,v 1.3 2004/07/22 13:38:56 boky Exp $";

  protected void process(String exepath, String[] args) throws Exception {
    BufferObjectReader in = new BufferObjectReader(getStdIn());
    BufferOutputStream out = getStdOutStream();
    GZIPOutputStream gout = new GZIPOutputStream(out);
    ObjectOutputStream oout = new ObjectOutputStream(gout);
    Object obj;
    try {
      while( !in.isFinished() ) {
        obj = in.readObject();
        oout.writeObject(obj);
        oout.flush();
        gout.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();
    gout.close();
    out.close();
  }
}
TOP

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

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.