小编Igo*_*aev的帖子

java.net.SocketException:recvfrom失败:EBADF(错误文件描述符)Android

我尝试从 Android 项目中的 URL 读取 json 文件。但奇怪的情况发生了。StringBuilder 成功获取前几个字符,但随后我得到 java.net.SocketException: recvfrom failed: EBADF (Bad file detector)

为什么我会得到这个异常?

我的代码有什么问题吗?)

JSON: http: //inlyfortesting.ucoz.net/artists.json

我的 JSON 解析器:

    public JSONArray getJSONFromUrl(String urlAsString) {
        // try to create JSONObject from string
        try {
            URL url = new URL(urlAsString);
            new DownloadFileTask().execute(url).get();
            jObj = new JSONArray(json);
        } catch (JSONException e) {
            Log.e("JSON Parser", "Error parsing data " + e.toString());
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (ExecutionException e) {
            e.printStackTrace();
        } …
Run Code Online (Sandbox Code Playgroud)

java url android json socketexception

2
推荐指数
1
解决办法
1万
查看次数

标签 统计

android ×1

java ×1

json ×1

socketexception ×1

url ×1