gpt4 book ai didi

java - 调试器将无法到达断点 - 而是引发异常

转载 作者:行者123 更新时间:2023-12-01 14:02:37 27 4
gpt4 key购买 nike

我在以下行设置断点:

   doc = Jsoup.connect(params[0]).get();

但由于某种原因,当我尝试从这一行开始跳过时,它会跳到该行

} catch (IOException e) {
e.printStackTrace();

并抛出异常(因此永远不会获得标题值),我不确定为什么。

有什么建议吗?

package com.example.test;

import java.io.IOException;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import android.app.Activity;
import android.app.ProgressDialog;
import android.os.AsyncTask;
import android.os.Bundle;
import android.widget.TextView;

public class MainActivity extends Activity {

TextView tv;
String url = "http://sheriff.org/apps/arrest/results.cfm?lname=ABBOTT&fname=LAUREA";
String tr;
Document doc;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

tv = (TextView) findViewById(R.id.TextView01);
new MyTask().execute(url);
}

private class MyTask extends AsyncTask<String, Void, String> {

ProgressDialog prog;

String title = "";

@Override
protected void onPreExecute() {
prog = new ProgressDialog(MainActivity.this);
prog.setMessage("Loading....");
prog.show();
}

@Override
protected String doInBackground(String... params) {
try {
doc = Jsoup.connect(params[0]).get();
Element tableElement = doc.select(".datagrid").first();

Elements tableRows = tableElement.select("tr");
for (Element row : tableRows) {
Elements cells = row.select("td");
if (cells.size() > 0) {
title = cells.get(0).text() + "; "
+ cells.get(1).text() + "; "
+ cells.get(2).text() + "; "
+ cells.get(3).text();
}
}
} catch (IOException e) {
e.printStackTrace();
}
return title;
}

@Override
protected void onPostExecute(String title) {
super.onPostExecute(title);
prog.dismiss();
tv.setText(title);
}
}
}

日志:

10-07 15:42:21.591: I/Adreno200-EGLSUB(7981): <ConfigWindowMatch:2165>: Format RGBA_8888.
10-07 15:42:21.611: D/memalloc(7981): ion: Mapped buffer base:0x5cbaa000 size:122880 offset:0 fd:60
10-07 15:42:21.611: E/(7981): Can't open file for reading
10-07 15:42:21.611: E/(7981): Can't open file for reading
10-07 15:42:21.621: I/Adreno200-EGLSUB(7981): <ConfigWindowMatch:2165>: Format RGBA_8888.
10-07 15:42:21.641: D/memalloc(7981): ion: Mapped buffer base:0x5ccd6000 size:614400 offset:0 fd:64
10-07 15:42:21.681: D/memalloc(7981): ion: Mapped buffer base:0x5cf02000 size:122880 offset:0 fd:67
10-07 15:42:21.721: D/memalloc(7981): ion: Mapped buffer base:0x5d166000 size:614400 offset:0 fd:70
10-07 15:42:21.771: D/memalloc(7981): ion: Mapped buffer base:0x5d2fc000 size:122880 offset:0 fd:74
10-07 15:42:22.091: W/System.err(7981): java.net.UnknownHostException: Unable to resolve host "sheriff.org": No address associated with hostname
10-07 15:42:22.281: W/System.err(7981): at java.net.InetAddress.lookupHostByName(InetAddress.java:463)
10-07 15:42:22.281: W/System.err(7981): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:279)
10-07 15:42:22.281: W/System.err(7981): at java.net.InetAddress.getAllByName(InetAddress.java:253)
10-07 15:42:22.281: W/System.err(7981): at libcore.net.http.HttpConnection.<init>(HttpConnection.java:71)
10-07 15:42:22.281: W/System.err(7981): at libcore.net.http.HttpConnection.<init>(HttpConnection.java:50)
10-07 15:42:22.281: W/System.err(7981): at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:351)
10-07 15:42:22.281: W/System.err(7981): at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:86)
10-07 15:42:22.291: W/System.err(7981): at libcore.net.http.HttpConnection.connect(HttpConnection.java:128)
10-07 15:42:22.291: W/System.err(7981): at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:308)
10-07 15:42:22.291: W/System.err(7981): at libcore.net.http.HttpEngine.connect(HttpEngine.java:303)
10-07 15:42:22.291: W/System.err(7981): at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:282)
10-07 15:42:22.291: W/System.err(7981): at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:232)
10-07 15:42:22.291: W/System.err(7981): at libcore.net.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:80)
10-07 15:42:22.291: W/System.err(7981): at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:425)
10-07 15:42:22.291: W/System.err(7981): at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:410)
10-07 15:42:22.291: W/System.err(7981): at org.jsoup.helper.HttpConnection.execute(HttpConnection.java:164)
10-07 15:42:22.291: W/System.err(7981): at org.jsoup.helper.HttpConnection.get(HttpConnection.java:153)
10-07 15:42:22.291: W/System.err(7981): at com.example.test.MainActivity$MyTask.doInBackground(MainActivity.java:46)
10-07 15:42:22.291: W/System.err(7981): at com.example.test.MainActivity$MyTask.doInBackground(MainActivity.java:1)
10-07 15:42:22.291: W/System.err(7981): at android.os.AsyncTask$2.call(AsyncTask.java:264)
10-07 15:42:22.291: W/System.err(7981): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
10-07 15:42:22.301: W/System.err(7981): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
10-07 15:42:22.301: W/System.err(7981): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208)
10-07 15:42:22.301: W/System.err(7981): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
10-07 15:42:22.301: W/System.err(7981): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
10-07 15:42:22.301: W/System.err(7981): at java.lang.Thread.run(Thread.java:856)
10-07 15:42:22.301: W/System.err(7981): Caused by: libcore.io.GaiException: getaddrinfo failed: EAI_NODATA (No address associated with hostname)
10-07 15:42:22.301: W/System.err(7981): at libcore.io.Posix.getaddrinfo(Native Method)
10-07 15:42:22.301: W/System.err(7981): at libcore.io.ForwardingOs.getaddrinfo(ForwardingOs.java:55)
10-07 15:42:22.301: W/System.err(7981): at java.net.InetAddress.lookupHostByName(InetAddress.java:448)
10-07 15:42:22.301: W/System.err(7981): ... 25 more
10-07 15:42:22.311: D/memalloc(7981): ion: Unmapping buffer base:0x5cbaa000 size:122880
10-07 15:42:22.311: D/memalloc(7981): ion: Unmapping buffer base:0x5cf02000 size:122880
10-07 15:42:22.311: D/memalloc(7981): ion: Unmapping buffer base:0x5d2fc000 size:122880
10-07 15:42:22.311: D/memalloc(7981): ion: Mapped buffer base:0x5ca92000 size:614400 offset:0 fd:54

最佳答案

我的 list 中缺少互联网权限,导致无法访问 URL。

关于java - 调试器将无法到达断点 - 而是引发异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19233197/

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