现在已经找了个实例,但是只能连接个服务器,我现在想连接成功后执行一系列的常用命令,比如登录用户名后,输入密码,查看信息操作之后再退出。
请大家多多指点!
请大家多多指点!
解决方案 »
- 如何通过反射获取类的成员变量
- 关于骑士巡游问题求一个界面
- 关于克隆的一个小问题
- 简易秒表,线程有问题,请高手相助
- Menubar上的menuitem被图像遮挡怎么办?
- 怎样才能让动画GIF在应用程序的一个界面上显示啊?
- 代码写出来了,但是不理解
- 谁能帮忙从算法上精简一下程序?这是一个数字游戏~有别的算法做吗?多谢~
- 请教:javascript 里有没有时间循环执行的函数,如我按住鼠标触发mousedown 事件函数时,反复执行我写的一个函数?
- 我为什么不能用中文作为条件查询出结果,请注意,不是无法显示中文结果!急救!
- JAVA中如何得到系统的日期和时间?
- 急:当目录中有新的文件时我需要得到一个通知
import java.io.*;
public class WebConnect{
public static void main(String[] args){
/*try{
Process process = Runtime.getRuntime().exec ("telnet bbs.njupt.edu.cn 23"+'\n');
InputStreamReader ir=new InputStreamReader(process.getInputStream());
LineNumberReader input = new LineNumberReader (ir);
String line;
while ((line = input.readLine ()) != null)
System.out.println(line);
}
catch (java.io.IOException e){
System.err.println ("IOException " + e.getMessage());
}*/
try{
Socket connection=new Socket(args[0],23);
System.out.println("Connection established:");
System.out.println("Local Connection Information");
System.out.println("\t address:" + connection.getLocalAddress());
System.out.println("\t port:" +connection.getLocalPort());
System.out.println("Remote connection Information:");
System.out.println("\t address:" + connection.getInetAddress());
System.out.println("\t port :"+connection.getPort());
// Socket user=new Socket(args[1],23);
// System.out.println("Connection established:");
// Process process =Runtime.getRuntime().exec("xxwan");
// System.out.println("longin finished");
connection.close();
}catch (UnknownHostException uhe){
System.err.println("Unknown host:"+args[0]);
System.out.println('\n'+"不能分析或无效");
}catch(IOException ioe){
System.err.println("IOException: "+ ioe);
System.out.println('\n'+"不能打开");
}
}
}命令提示符下输入: java WebConnect 10.10.136.32
可以输出
Connection established:
Local Connection Information
address:/10.10.133.134
port:1477
Remote connection Information:
address:/10.10.136.32
port :23
但我现在想在连接后,以某个用户名登录,并输入密码,然后再退出,不知道怎么实现?