try{
}catch(Exception ex)
{
如占用,一定报错
}
}catch(Exception ex)
{
如占用,一定报错
}
解决方案 »
- java中可以这样使用字符串数组吗?
- java中interface的方法默认修饰符是public abstract。有sun官方文档吗?
- 急!我的java界面显数据库信息时addElement(E) 的调用未经检查(在线等!)
- help! Windows中有哪个命令可以把一个文件中的特定字符串替换成另一个字符串
- 如何更改本页面的url地址啊
- 求助:Exception in thread "main" java.lang.NullPointerException
- 再请教各位一个问题
- 我的HelloWorld Applet在Appletviewer中正常,在IE中是空白
- iPlanet下怎样设置动态链接库的路径?
- 关于 -deprecation 参数的问题
- 求换行符号
- 有谁可以提供Jbuilder 7(或8)的下载地址?
try {
s = new ServerSocket(i);
}
catch (IOException ex) {
System.out.println("端口﹕" + i + " 已被占用");
}
try {
s.close;
}
catch (IOException ex) {
System.out.println("");
}
}
import java.io.*;public class HighPortScanner {
public static void main(String args[]) { String host="localhost";
int begin=0;
int end=65336;
if(args.length>0) {
host=args[0];
}
if(args.length>1) {
begin=Integer.parseInt(args[1]);
end=Integer.parseInt(args[2]);
} try{
InetAddress theAddress=InetAddress.getByName(host); for(int i=begin;i<end;i++) { BufferedReader networkIn=null; try {
Socket theSocket=new Socket(theAddress,i);
System.out.println("there is a serve on port"+i+" of "+host);
networkIn=new BufferedReader(new InputStreamReader(theSocket.getInputStream()));
System.out.println(networkIn.readLine());
} catch (IOException e) {
System.out.println("there is no service on port "+i);
} }//END FOR
}//END TRY catch(UnknownHostException e) {
System.err.println(e);
}
}//END MAIN}
回复人: littlecpu(嘿,哥们,你欠我分,快给咯) ( ) 信誉:100 2003-05-15 12:35:00 得分:0
try{
}catch(Exception ex)
{
如占用,一定报错
}