gpt4 book ai didi

java - 如何修复 java.lang.StringIndexOutOfBoundsException : length=225; regionStart=4; regionLength=-2

转载 作者:太空宇宙 更新时间:2023-11-04 10:02:10 25 4
gpt4 key购买 nike

这是我的错误:

`E/AndroidRuntime:致命异常:AsyncTask #2 进程:com.example.yasht.recyclerviewrss,PID:4097 java.lang.RuntimeException:执行 doInBackground() 时发生错误

    at android.os.AsyncTask$3.done(AsyncTask.java:325)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)

at java.lang.Thread.run(Thread.java:761)
Caused by: java.lang.StringIndexOutOfBoundsException: length=225; regionStart=4; regionLength=-2
at java.lang.String.substring(String.java:1931)
at com.example.yasht.recyclerviewrss.m_Rss.RssParser.parseRSS(RssParser.java:107)
at com.example.yasht.recyclerviewrss.m_Rss.RssParser.doInBackground(RssParser.java:47)
at com.example.yasht.recyclerviewrss.m_Rss.RssParser.doInBackground(RssParser.java:21)`

我发生错误的来源:

case XmlPullParser.END_TAG:

if(!isSiteMeta)
{
if(tagName.equalsIgnoreCase("title"))
{
article.setTitle(tagValue);
}else if(tagName.equalsIgnoreCase("description"))
{
String desc=tagValue;

//EXTRACT IMAGE FROM DESC
// error in this line =>
String
imageUrl=desc.substring(desc.indexOf("src=")+5,desc.indexOf("jpg")+3);
article.setImageurl(imageUrl);`

最佳答案

似乎jpg不在desc中,因此desc.indexOf("jpg")返回-1+3给出-2!

关于java - 如何修复 java.lang.StringIndexOutOfBoundsException : length=225; regionStart=4; regionLength=-2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53349288/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com