The abstract Process class encapsulates a
process , it is an executing program.The exec() return an instance of a subclass of Process that can be used to control the process and obtain information about it.
The class Process provides methods for performing input from the process, performing output to the process, waiting for the process to complete, checking the exit status of the process, and destroying the process.
Process Contains the abstract methods as shown below.
ProcessDemo CODE import java.io.IOException; OUTPUT 1 DESCRIPTION Here,in the above example program Line A,Line B represents how to create Process in java.Here exec() is used to control the process and obtain the information about it.In Line C we can get InputStream of the subprocess.In Line D we can Terminate the process,in Line E we can print the exit value of subprocess.In Line F and Line G we can create another process.In Line H we can get the OutputStream of the subprocess, then we can print the two lines of code. THINGS TO TRY If we execute this program in our desktops it will display a notepad window and the remaing good,bad code will be print in the command promt.
|