需要 Http 连接和 WAP 连接
我有成功显示 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论