Hi all,
I have a small App that reads in a
Java Source File, I want my app to run a batch file to compile the Source. (File contains 'javac myclass.java'.
After this has run, I want to read in the output from the compilation (ie warnings, errors etc). My code executes the batch file correctly, but when I try to read in the output, all thats read in is the command from the batch file (ie javac myclass.java)
Here is the code that executes the batch file (command) & uses InputStream to read in the data at the command prompt.
try
{
Process child = Runtime.getRuntime().exec(command);
Runtime.getRuntime().wait();
InputStream in = child.getInputStream();
int c;
String szOutText = new String("");
while ((c = in.read()) != -1)
{
char cText = ((char)c);
String szStr = String.valueOf(cText);
szOutText = szOutText + szStr;
}
System.out.println(szOutText);
textOut.setText(szOutText);
in.close();
} catch(IOException e)
I tried changing the batch file from javac myclass.java to javac myclass.java << output.txt but this just creates the empty text file & the errors are still displayed on screen,
What am I doing wrong? or can this be done at all?
Thanks.
Dave