需要 Http 连接和 WAP 连接

发布于 2024-08-02 21:44:50 字数 1722 浏览 10 评论 0原文

我有成功显示 html 的代码

import java.io.DataInputStream;
import java.io.IOException;

import javax.microedition.io.Connector;
import javax.microedition.io.HttpConnection;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.StringItem;
import javax.microedition.lcdui.TextField;
import javax.microedition.midlet.MIDlet;


public class Example extends MIDlet implements CommandListener {
.
.
.
.
.

private String requestUsingGET(String URLString) throws IOException {
    HttpConnection hpc = null;
    DataInputStream dis = null;
    boolean newline = false;
    String content = "";
    try {
      hpc = (HttpConnection) Connector.open(URLString);
      dis = new DataInputStream(hpc.openInputStream());
      int character;

      while ((character = dis.read()) != -1) {
        if ((char) character == '\\') {
          newline = true;
          continue;
        } else {
          if ((char) character == 'n' && newline) {
            content += "\n";
            newline = false;
          } else if (newline) {
            content += "\\" + (char) character;
            newline = false;
          } else {
            content += (char) character;
            newline = false;
          }
        }

      }
      if (hpc != null)
        hpc.close();
      if (dis != null)
        dis.close();
    } catch (IOException e2) {
    }

    return content;
  }
}

,但是除了我想显示 WAP.what 之外,还可以在我的代码中添加此内容吗?
显示WAP浏览器。

因为当我尝试访问 wap.yahoo.com 时,系统没有响应。

I have code that successfully displays html

import java.io.DataInputStream;
import java.io.IOException;

import javax.microedition.io.Connector;
import javax.microedition.io.HttpConnection;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.StringItem;
import javax.microedition.lcdui.TextField;
import javax.microedition.midlet.MIDlet;


public class Example extends MIDlet implements CommandListener {
.
.
.
.
.

private String requestUsingGET(String URLString) throws IOException {
    HttpConnection hpc = null;
    DataInputStream dis = null;
    boolean newline = false;
    String content = "";
    try {
      hpc = (HttpConnection) Connector.open(URLString);
      dis = new DataInputStream(hpc.openInputStream());
      int character;

      while ((character = dis.read()) != -1) {
        if ((char) character == '\\') {
          newline = true;
          continue;
        } else {
          if ((char) character == 'n' && newline) {
            content += "\n";
            newline = false;
          } else if (newline) {
            content += "\\" + (char) character;
            newline = false;
          } else {
            content += (char) character;
            newline = false;
          }
        }

      }
      if (hpc != null)
        hpc.close();
      if (dis != null)
        dis.close();
    } catch (IOException e2) {
    }

    return content;
  }
}

But other than I want to display WAP.what to add on this in my code?
To display the WAP browser.

Because when I tried to address wap.yahoo.com is not in response by the system.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文