Using the getInputStream() method of Process class output of the executed command can be printed by reading the stream.
public Process exec(String command) throws IOException - Executes the specified string command in a separate process.Ĭmd /c which is used with the command has the following explanantion.public static Runtime getRuntime() - Returns the runtime object associated with the current Java application.Runtime.getRuntime().exec method is used to run the command. Here it can be seen that directory listing is displayed for the directory which happens to be the workspace directory