【问题标题】:Java issue, java.io.FileNotFoundException:Java 问题,java.io.FileNotFoundException:
【发布时间】:2013-06-19 19:18:26
【问题描述】:

我正在尝试从 RSS 提要中逐行读取。

我一直收到这个错误;

java.io.FileNotFoundException: (Android App 的位置名称)

自从它被读取以来,从 RSS 提要并实际输出了一些 xml,我看不出哪里可能有错误。有人遇到过这个问题吗?

        URL url = new URL(urlText);
        in = new BufferedReader(new InputStreamReader(url.openStream()));

        String inputLine;
        while ((inputLine=in.readLine()) != null) {
            System.out.println(inputLine);
            count++;
            try{
                DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
                DocumentBuilder dBuilder= dbFactory.newDocumentBuilder();
                Document doc = dBuilder.parse(inputLine);
               doc.getDocumentElement().normalize();
            }
            catch(MalformedURLException e){
                System.out.println(e.getMessage());

            }

        }

【问题讨论】:

  • 异常来自哪一行?
  • 哪一行引发了错误?
  • 你能发布 logcat 并向我们展示你得到错误的行吗?
  • urlText 的值是多少?它指向一个文件吗?

标签: java android xml parsing


【解决方案1】:

我猜您使用了代理,这就是您遇到 url.openStream() 问题的原因。尝试设置代理配置,希望可以。

String proxyUser = "";
String proxyPassword = "";
String proxyAddress = "";
int proxyPort = 8080;
InetSocketAddress sa = new InetSocketAddress(proxyAddress, proxyPort);
Proxy proxy = new Proxy(Proxy.Type.HTTP, sa);
URLConnection conn = url.openConnection(proxy);

【讨论】:

    猜你喜欢
    • 2014-07-07
    • 2020-08-14
    • 2013-11-02
    • 1970-01-01
    • 2011-05-15
    • 2015-08-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多