Package org.jboss.fresh.shell.commands

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

package org.jboss.fresh.shell.commands;

import java.io.PrintWriter;
import java.io.ObjectInputStream;
import java.util.zip.GZIPInputStream;
import org.jboss.fresh.shell.AbstractExecutable;
import org.jboss.fresh.io.BufferWriter;
import org.jboss.fresh.io.BufferObjectWriter;
import org.jboss.fresh.io.BufferInputStream;

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

  protected void process(String exepath, String[] args) throws Exception {
    BufferObjectWriter out = new BufferObjectWriter(getStdOut());
    BufferInputStream in = getStdInStream();
    GZIPInputStream gin = new GZIPInputStream(in);
    ObjectInputStream oin = new ObjectInputStream(gin);
    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();
            gin.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.GunzipExe

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.