Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org

Feedback: irt.org FAQ Knowledge Base Q1486

Feedback on: irt.org FAQ Knowledge Base Q1486

Sent by chris on September 07, 2001 at 02:02:43: - feedback #3139

Comments:
I can invoke a new process on MS Windows, but can't on Alpha Unix.
// ##############################
Runtime r = Runtime.getRuntime();
Process p = null;
//p = r.exec("ls -l > filelist.txt");
p = r.exec("D:\\WINNT\\notepad.exe ");


Sent by Mike Weerdenburg on September 03, 2002 at 00:23:19: - feedback #4118

Length:
Too short

Comments:
If you want to grab the output from an executable then use the following code:

// You need the following imports...
import java.lang.System;
import java.lang.Runtime;
import java.io.IOException;

// The executable...
String strFile = "c:/test.exe";

// The output of the executable...
String strResult = "";

Process obProcess = null;

// Byte-Counter...
int intByte = -1;

// Runtime Environement
Runtime obRuntime = Runtime.getRuntime();

try
{
obProcess = obRuntime.exec( strFile );
InputStream obInputStream = obProcess.getInputStream();
intByte = obInputStream.read();
while ( intByte != -1 )
{
strResult += ( char ) intByte;
intByte = obInputStream.read();
}
}
catch ( Exception e )
{
System.out.println("Error : " + e);
}
System.out.println("strResult : " + strResult);


©2018 Martin Webb