P
publius36
I have a DOS program I am trying to supply input to using Java.
Reading from The Java Class Libraries, 2nd Ed. java.lang.Process class -
the material presented seems to imply that I will be able to do
this.
The program most definately uses just stdio... (in) being the keyboard and
(out) being the consol.
Well I can't get it to work and being the presistant bugger that i am I have
switch tactics so I can more up the learning curve.
I have resorted to just trying to display the output of mem.exe.
here is the source ::: test.java
import java.io.*;
import java.lang.*;
public class test
{ public static void main(String[] args)
{
int ch;
int status;
try
{
Process process = Runtime.getRuntime().exec("mem.exe");
InputStream in = process.getInputStream();
BufferedInputStream buf = new BufferedInputStream(in);
//try
//{
//status = process.waitFor();
//}
//catch (InterruptedException e) {status = -1;}
try
{
while((ch = buf.read()) != -1)
{
System.out.print((char)ch);
}
}
catch (IOException e) {System.out.println(e);}
//in.close();
//buf.close();
//process.destroy();
//Runtime.getRuntime().gc();
//Runtime.getRuntime().exit(-1);
//System.out.print('\n');
}
catch (IOException e) {System.out.println(e);}
}
}
It works the first time I run the class file with java test.
However, the next attempt hangs and requires a system restart inorder to get
the code to display the results.
The commented code in test.java are my attempts to do various things to
clean up this issue of not displaying the results.
Does anyone have a clue or suggestion...
thanks,
publius36
Reading from The Java Class Libraries, 2nd Ed. java.lang.Process class -
the material presented seems to imply that I will be able to do
this.
The program most definately uses just stdio... (in) being the keyboard and
(out) being the consol.
Well I can't get it to work and being the presistant bugger that i am I have
switch tactics so I can more up the learning curve.
I have resorted to just trying to display the output of mem.exe.
here is the source ::: test.java
import java.io.*;
import java.lang.*;
public class test
{ public static void main(String[] args)
{
int ch;
int status;
try
{
Process process = Runtime.getRuntime().exec("mem.exe");
InputStream in = process.getInputStream();
BufferedInputStream buf = new BufferedInputStream(in);
//try
//{
//status = process.waitFor();
//}
//catch (InterruptedException e) {status = -1;}
try
{
while((ch = buf.read()) != -1)
{
System.out.print((char)ch);
}
}
catch (IOException e) {System.out.println(e);}
//in.close();
//buf.close();
//process.destroy();
//Runtime.getRuntime().gc();
//Runtime.getRuntime().exit(-1);
//System.out.print('\n');
}
catch (IOException e) {System.out.println(e);}
}
}
It works the first time I run the class file with java test.
However, the next attempt hangs and requires a system restart inorder to get
the code to display the results.
The commented code in test.java are my attempts to do various things to
clean up this issue of not displaying the results.
Does anyone have a clue or suggestion...
thanks,
publius36