Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Process p = Runtime.getRuntime().exec("C:\j2sdk1.4.0bin\helloworld.java");
- BufferedReader input =
- new BufferedReader(new InputStreamReader(p.getInputStream()));
- while ((line = input.readLine()) != null)
- System.out.println(line);
- input.close();
- Runtime r = Runtime.getRuntime();
- mStartProcess = r.exec(applicationName, null, fileToExecute);
- StreamLogger outputGobbler = new StreamLogger(mStartProcess.getInputStream());
- outputGobbler.start();
- int returnCode = mStartProcess.waitFor();
- class StreamLogger extends Thread{
- private InputStream mInputStream;
- public StreamLogger(InputStream is) {
- this.mInputStream = is;
- }
- public void run() {
- try {
- InputStreamReader isr = new InputStreamReader(mInputStream);
- BufferedReader br = new BufferedReader(isr);
- String line = null;
- while ((line = br.readLine()) != null) {
- System.out.println(line);
- }
- } catch (IOException ioe) {
- ioe.printStackTrace();
- }
- }
- }
- public Process exec(String command, String envp[], File dir)
- @param command a specified system command.
- @param envp array of strings, each element of which
- has environment variable settings in format
- <i>name</i>=<i>value</i>.
- @param dir the working directory of the subprocess, or
- <tt>null</tt> if the subprocess should inherit
- the working directory of the current process.
Add Comment
Please, Sign In to add comment