kxml 用于解析网站数据

发布于 2024-12-27 21:52:19 字数 2005 浏览 1 评论 0原文

我目前正在尝试使用 netbeans 6.9.1 开发一个应用程序,但是当我尝试运行该程序时,出现以下错误

Uncaught exception: java.lang.IllegalArgumentException
    at javax.microedition.io.Connector.openPrim(), bci=31
    at javax.microedition.io.Connector.open(), bci=3
    at javax.microedition.io.Connector.open(), bci=3
    at javax.microedition.io.Connector.open(), bci=2
    at RSSParser$1.run(RSSParser.java:32)

此错误来自此代码

public void parse(final String url) {
Thread t = new Thread() {
  public void run() {
    // set up the network connection
    HttpConnection hc = null;

    try {
      hc = (HttpConnection)Connector.open(url);
      parse(hc.openInputStream());
    }
    catch (IOException ioe) {
      mRSSListener.exception(ioe);
    }
    finally {
      try { if (hc != null) hc.close(); }
      catch (IOException ignored) {}
    }
  }
};
t.start();
}

此方法正在从此处的另一个类调用

public void startApp() {
if (mDisplay == null)
  mDisplay = Display.getDisplay(this);

if (mInitialized == false) {
  // Put up the waiting screen.
  Screen waitScreen = new Form("Connecting...");
  mDisplay.setCurrent(waitScreen);
  // Create the title list.
  mTitleList = new List("Headlines", List.IMPLICIT);
  mExitCommand = new Command("Exit", Command.EXIT, 0);
  mDetailsCommand = new Command("Details", Command.SCREEN, 0);
  mTitleList.addCommand(mExitCommand);
  mTitleList.addCommand(mDetailsCommand);
  mTitleList.setCommandListener(this);
  // Start parsing.
  String url = getAppProperty("RSSMIDlet.URL");
  RSSParser parser = new RSSParser();
  parser.setRSSListener(this);
  parser.parse(url);
  mInitialized = true;
}
else
  mDisplay.setCurrent(mTitleList);
}

当我调试它时,它说“String url”为空,我该如何解决这个问题?

我还在字符串 url 中放入了一个 url,如下所示:

String url = getAppProperty("RSSMIDlet.http://wwww.anything.com");
String url = getAppProperty("http://wwww.anything.com");

但这并不重要,因为第一种方式有一个默认的 url 可供访问。

有人知道我在这里做错了什么吗?

I am currently trying to develop an application using netbeans 6.9.1, but when I try to run the program I am getting the following error

Uncaught exception: java.lang.IllegalArgumentException
    at javax.microedition.io.Connector.openPrim(), bci=31
    at javax.microedition.io.Connector.open(), bci=3
    at javax.microedition.io.Connector.open(), bci=3
    at javax.microedition.io.Connector.open(), bci=2
    at RSSParser$1.run(RSSParser.java:32)

this error is coming from this code

public void parse(final String url) {
Thread t = new Thread() {
  public void run() {
    // set up the network connection
    HttpConnection hc = null;

    try {
      hc = (HttpConnection)Connector.open(url);
      parse(hc.openInputStream());
    }
    catch (IOException ioe) {
      mRSSListener.exception(ioe);
    }
    finally {
      try { if (hc != null) hc.close(); }
      catch (IOException ignored) {}
    }
  }
};
t.start();
}

This method is being called from another class here

public void startApp() {
if (mDisplay == null)
  mDisplay = Display.getDisplay(this);

if (mInitialized == false) {
  // Put up the waiting screen.
  Screen waitScreen = new Form("Connecting...");
  mDisplay.setCurrent(waitScreen);
  // Create the title list.
  mTitleList = new List("Headlines", List.IMPLICIT);
  mExitCommand = new Command("Exit", Command.EXIT, 0);
  mDetailsCommand = new Command("Details", Command.SCREEN, 0);
  mTitleList.addCommand(mExitCommand);
  mTitleList.addCommand(mDetailsCommand);
  mTitleList.setCommandListener(this);
  // Start parsing.
  String url = getAppProperty("RSSMIDlet.URL");
  RSSParser parser = new RSSParser();
  parser.setRSSListener(this);
  parser.parse(url);
  mInitialized = true;
}
else
  mDisplay.setCurrent(mTitleList);
}

When I debug it, it is saying the "String url" is null, how do I solve this?

I have also put a url in the string url like so:

String url = getAppProperty("RSSMIDlet.http://wwww.anything.com");
String url = getAppProperty("http://wwww.anything.com");

but this shouldn't matter as the first way has a default url to go to.

Does anybody know what I am doing wrong here?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

北音执念 2025-01-03 21:52:19

这有帮助吗?

String url = "http://wwww.anything.com";

如果您参考文章在 J2ME 中解析 XML,您应该了解它是从 2002 年开始的,kxml 从那时起一直在进步。

如果您不幸无法运行 midlet,此文档可能会你感兴趣。恕我直言,您需要通过在清单文件中将属性名称 RSSMIDlet.URL 设置为 http://wwww.anything.com 来配置 midlet。

Does this help?

String url = "http://wwww.anything.com";

If you refer to the article Parsing XML in J2ME, you should be aware it is from 2002 and kxml has advanced since then.

If you are in the unfortunate situation to get the midlet running, this documentation may be of interest you. IMHO, you need to configure the midlet by setting the property name RSSMIDlet.URL to http://wwww.anything.com in the manifest file.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文