com.jfw.util
Class ExecProgram

java.lang.Object
  extended by com.jfw.util.ExecProgram

public final class ExecProgram
extends java.lang.Object

Execute a shell program.


Constructor Summary
ExecProgram(java.lang.String programToExec)
          Create an instance.
ExecProgram(java.lang.String[] programToExec)
          Create an instance.
ExecProgram(java.lang.String[] programToExec, java.lang.String[] env)
          Create an instance.
ExecProgram(java.lang.String[] programToExec, java.lang.String[] env, java.lang.String workingDirectory)
          Create an instance.
ExecProgram(java.lang.String programToExec, java.lang.String[] env)
          Create an instance.
ExecProgram(java.lang.String programToExec, java.lang.String[] env, java.lang.String workingDirectory)
          Create an instance.
 
Method Summary
 void close()
          Call methods closeStreams() and stopProcess()
 void closeStreams()
          Close the streams.
 void finalize()
          Call super.finalize() and method close().
 java.io.BufferedReader getError()
          Get the error output stream.
 java.io.BufferedReader getOutput()
          Get the standard output stream.
 java.lang.Process getProcess()
          Get attribute currentProcess.
 java.lang.String readErrorLine()
          Get next line from the error stream.
 java.lang.String readLine()
          Get next line from the standard stream.
 java.lang.String showOutput()
          Return the string contrent saved in outputHistory.
 void stopProcess()
          Stop the process.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExecProgram

public ExecProgram(java.lang.String programToExec)
            throws JFWGenericException
Create an instance.

Parameters:
programToExec - the program to execute with absolute path.
Throws:
JFWGenericException

ExecProgram

public ExecProgram(java.lang.String programToExec,
                   java.lang.String[] env)
            throws JFWGenericException
Create an instance.

Parameters:
programToExec - the program to execute with absolute path.
env - environment parameters.
Throws:
JFWGenericException

ExecProgram

public ExecProgram(java.lang.String[] programToExec)
            throws JFWGenericException
Create an instance.

Parameters:
programToExec - the program to execute in index 0 and after the program parameters.
Throws:
JFWGenericException

ExecProgram

public ExecProgram(java.lang.String[] programToExec,
                   java.lang.String[] env)
            throws JFWGenericException
Create an instance.

Parameters:
programToExec - the program to execute in index 0 and after the program parameters.
env - environment parameters.
Throws:
JFWGenericException

ExecProgram

public ExecProgram(java.lang.String programToExec,
                   java.lang.String[] env,
                   java.lang.String workingDirectory)
            throws JFWGenericException
Create an instance.

Parameters:
programToExec - the program to execute with realtive path.
env - environment parameters.
workingDirectory - the working directrory
Throws:
JFWGenericException

ExecProgram

public ExecProgram(java.lang.String[] programToExec,
                   java.lang.String[] env,
                   java.lang.String workingDirectory)
            throws JFWGenericException
Create an instance.

Parameters:
programToExec - the program to execute in index 0 and after the program parameters.
env - environment parameters.
workingDirectory - the working directrory
Throws:
JFWGenericException
Method Detail

getOutput

public java.io.BufferedReader getOutput()
Get the standard output stream.

Returns:
the standard output stream.

getError

public java.io.BufferedReader getError()
Get the error output stream.

Returns:
the error output stream.

readLine

public java.lang.String readLine()
                          throws JFWGenericException
Get next line from the standard stream. The line is also added at outputHistory.

Returns:
next line from the standard stream.
Throws:
JFWGenericException

readErrorLine

public java.lang.String readErrorLine()
                               throws JFWGenericException
Get next line from the error stream.

Returns:
next line from the error stream.
Throws:
JFWGenericException

showOutput

public java.lang.String showOutput()
Return the string contrent saved in outputHistory.

Returns:
the string contrent saved in outputHistory.

getProcess

public java.lang.Process getProcess()
Get attribute currentProcess.

Returns:
attribute currentProcess.

closeStreams

public void closeStreams()
Close the streams.


stopProcess

public void stopProcess()
Stop the process.


close

public void close()
Call methods closeStreams() and stopProcess()


finalize

public void finalize()
              throws java.lang.Throwable
Call super.finalize() and method close().

Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable