//filename 1.xml
<category
hello world
</category>
//when iam trying to parse this file using the following code it throws String index out of range: -1
output: startPos: -1
endPosi: -1
String dataLine = nextLine.trim();
int startPos = dataLine.indexOf(startToken);
logger.debug("startPos: " + startPos);
int endPosi = dataLine.lastIndexOf(endToken);
logger.debug("endPosi: " + endPosi);
// 2.xml it parses this file which contains the following line
<category hello world </category>
//这两个文件之间的唯一差别是第一个文件的内容是在三行和第二文件的内容是在一个单一的线路。字符串索引超出范围:-1
什么是''startToken''?另外,你的XML无效。它应该是“'''(注意'>') –
2013-03-25 11:58:03
String startToken =”<“+”category“+”“; – srp 2013-03-25 11:58:57
我敢打赌,第一行是'
raina77ow
2013-03-25 12:01:11