1
我刚刚下载了Java ME Platform SDK 3.0并创建了我的第一个Midlet(来自一些Oracle教程)。在模拟器上工作正常。当我在我的诺基亚N97部署它,我能够尽快,我按下“连接”,并允许继续我得到一个IOException异常运行它,但是:-1JavaME Midlet无法建立HTTP连接
下面是代码:
package hello;
import java.io.*;
import javax.microedition.io.*;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class HelloMIDlet extends MIDlet implements CommandListener {
...
private void connect() {
HttpConnection hc = null;
InputStream in = null;
String url = getAppProperty("HitMIDlet.URL");
try {
hc = (HttpConnection)Connector.open("http://www.google.ch");
in = hc.openInputStream();
byte[] raw = new byte[10];
int length = in.read(raw);
in.close();
hc.close();
// Show the response to the user.
String s = new String(raw, 0, length);
mMessageItem.setText(s);
}
catch (IOException ioe) {
mMessageItem.setText(ioe.toString());
}
mDisplay.setCurrent(mMainForm);
}
}
非常感谢。就是这样。很简单。 – 2010-11-18 09:56:23
@Marcel Menz欢迎您:) – 2010-11-18 10:06:19