一个简单的联网问题:
我的开发环境是:J2ME Version 1.0.3 Beta,J2SE Version 1.3.0_01,apache
1.3.27,并配置好apache,在IE上输入http://127.0.0.1:8080/a.html能正常显示
我输入以下代码:
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.io.*;
import java.io.*;
public class HTTPTest extends MIDlet {
private Display display;
/** Constructor */
public HTTPTest() {
display=Display.getDisplay(this);
}
/** Main method */
public void startApp() {
try{
String url="http://127.0.0.1:8080/a.html";
HttpConnection hc=(HttpConnection)Connector.open(url);
DataInputStream dis=new
DataInputStream(hc.openDataInputStream());
String content="";
int ic;
while((ic=dis.read())!=-1) content=content+(char)ic;
Form f=new Form("HTTP Test");
f.append(content);
display.setCurrent(f);
}catch(Exception e){
System.out.println(e);
notifyDestroyed();
}
}
/** Handle pausing the MIDlet */
public void pauseApp() {
}
/** Handle destroying the MIDlet */
public void destroyApp(boolean unconditional) {
}
/** Quit the MIDlet */
}
当我编译,运行后,点击Launch后,出现
javax.microedition.io.ConnectionNotFoundException错误,请高手指点。