Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

Feedback on: irt.org FAQ Knowledge Base Q1486

irt.org | About | Feedback | 4118 [ previous next ]

Feedback on:
irt.org FAQ Knowledge Base Q1486

Sent by
Mike Weerdenburg on September 03, 2002 at 00:23:19:

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);


Other feedback on 'irt.org FAQ Knowledge Base Q1486' - show all


Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 21st December 2007. Maintained by: Martin Webb
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.