【发布时间】:2011-07-16 09:05:04
【问题描述】:
我真的被这个异常困住了
private static void getUserComment(String s) {
while(s.contains("author'>")){
System.out.println(s.substring(s.indexOf("author'>"),
s.indexOf("<div id='")));
s = s.substring(0, s.indexOf("author'>")) +
s.substring(s.indexOf("<div id='"+9));
}
}
【问题讨论】:
-
你的输入字符串是什么样的?
-
哪一行导致异常?
-
打印和子字符串语句似乎都产生了这个异常
-
输入是一个 html 页面,基本上是这个 UR:Lhttp://sabq.org/sabq/user/news.do?section=5&id=20908 我试图提取有用的信息,例如用户名以及评论者的评论,不知道这样做对不对?
-
获取适当的 HTML 解析器,将页面加载到 DOM 中,然后查询 DOM(例如,如果支持,则使用 XPath)。 HTML Parser 开源项目可能会对您有所帮助。
标签: java exception indexoutofboundsexception