应该是 Long和long数的比较出现了问题,具体见内部

cnhuai 2008-06-22 04:16:43
for(long i=first;i<=end;i++)
{

//到现有的IP表里面比较
try{
FileReader fr1=new FileReader("C:\\test1\\first-end-int.txt");
BufferedReader br1=new BufferedReader(fr1);
try{
int j=0;
while(br1.ready()&&j==0)//while1
{
String[] firstendline;
firstendline=br1.readLine().split("\\s+");

//System.out.println("er"+firstendline[0]);
if(Long.parseLong(firstendline[0])<=(long)i&&Long.parseLong(firstendline[1])>=(long)i)
{
System.out.println("IP存在库中");
j++;
}

}

if(j==0)
System.out.println("yi"+ipend.longToIP(i));

}finally{
fr1.close();
}
}
catch(IOException e)
{
System.out.println("error333");
}

}

***************
提示
java.lang.NumberFormatException: For input string: ""
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Long.parseLong(Unknown Source)
at java.lang.Long.parseLong(Unknown Source)
at ipfindlack.main(ipfindlack.java:46)
Exception in thread "main"

应该是上面if(Long.parseLong(firstendline[0])<=(long)i&&Long.parseLong(firstendline[1])>=(long)i)
有错误
大家来帮忙
...全文
91 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
cnhuai 2008-06-22
  • 打赏
  • 举报
回复
解决了 C:\\test1\\first-end-int.txt文件有一行是空行
谢谢了java2000_net
cnhuai 2008-06-22
  • 打赏
  • 举报
回复
你是说firstendline是空的吗
我刚看了 不空
老紫竹 2008-06-22
  • 打赏
  • 举报
回复
java.lang.NumberFormatException: For input string: ""

明显,你用于解析的字符串是空啊!

你在解析前打印出来看看就知道了

System.out.println(Arrays.toString(firstendline));

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧