I know that there are several APIs available to do this but I want to know whether is there any way to carry out telnet / ftp using Runtime.exec() command in java. Because what I am doing is not working-
I created the process as follow:
Runtime rt=Runtime.getRuntime();
Process p=rt.exec("telnet 12.42.28.123 25");
I got the input stream of this process by:
InputStreamReader isr1=new InputStreamReader
(p.getInputStream());
I got the error stream of this process by:
InputStreamReader isr2=new InputStreamReader
(p.getErrorStream());
I got the output stream of this process by:
PrintWriter pw=new PrintWriter
( p.getOutputStream() );
Now I should be able to read the input stream as well as error stream of this process. Ishould also be able to write further commands on the output stream of this process but neither i/p,err stream, nor o/p stream is working and the function p.waitFor() always returns -1. I am using Windows XP operating system with java version
2007-07-09
02:36:49
·
3 answers
·
asked by
Mickey
1
in
Computers & Internet
➔ Programming & Design