标题:程序运行时发生异常
只看楼主
xyyhc
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2007-7-20
 问题点数:0 回复次数:3 
程序运行时发生异常
不知道什么原因运行时候发生异常????

建立并等待连接~~~~
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String ind
ex out of range: -6
at java.lang.String.substring(String.java:1768)
at ReadTestFile.<init>(ReadTestFile.java:14)
at ServerThread.<init>(ServerThread.java:16)
at MultiServer.main(MultiServer.java:11)
Press any key to continue...
搜索更多相关主题的帖子: 运行 
2007-07-20 14:35
千里冰封
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:灌水之王
等 级:版主
威 望:155
帖 子:28477
专家分:59
注 册:2006-2-26
得分:0 

数组下标越界异常
在你的程序ReadTestFile里面第14行


可惜不是你,陪我到最后
2007-07-20 15:42
无理取闹
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:53
帖 子:4264
专家分:0
注 册:2006-7-26
得分:0 

老千永远都不会厌倦回答别人的问题,佩服


win32汇编
病毒 加密
目前兴趣所在
2007-07-20 17:07
xyyhc
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2007-7-20
得分:0 
哎,好像都没有用到数组,是不是字符串长度不够,应该怎么该啊???
public ReadTestFile() throws IOException{
bufReader=new BufferedReader(new FileReader("test.txt"));//
//
String s=bufReader.readLine();//
int i1=s.indexOf('@');//
int i2=s.indexOf("分钟");//
s=s.substring(i1+1,i2);//at ReadTestFile.<init>(ReadTestFile.java:14)

testTime=Integer.parseInt(s)*60*1000;//
//
s=bufReader.readLine().trim();//
correctAnswer=s.substring(s.indexOf("@"+1));//
}
2007-07-21 12:07



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-156854-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.458528 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved