Well i was making the following program:
which is also in tutorial
public class FirstExample extends MIDlet {
private Display display;
String url = "http://127.0.0.1:8080/examples/t.txt";
public FirstExample() {
display = Display.getDisplay(this);
}
/**
* This method is invoked when the MIDlet is activated
*/
public void startApp() {
try {
getViaStreamConnection(url);
} catch (IOException e) {
//Handle Exceptions any other way you like.
System.out.println("IOException " + e);
e.printStackTrace();
}
}
/**
* Pause, discontinue....
*/
public void pauseApp() { }
/**
* Destroy cleans up everything.
*/
public void destroyApp(boolean unconditional) { }
/**
* read url via stream connection
*/
void getViaStreamConnection(String url)
throws IOException {
StreamConnection c = null;
InputStream s = null;
StringBuffer b = new StringBuffer();
TextBox t = null;
try {
c = (StreamConnection)Connector.open(url);
s = c.openInputStream();
int ch;
while((ch = s.read()) != -1) {
b.append((char) ch);
}
System.out.println(b.toString());
t = new TextBox("hello....",
b.toString(), 1024, 0);
} finally {
if(s != null) {
s.close();
}
if(c != null) {
c.close();
}
}
// display the contents of the file in a text box.
display.setCurrent(t);
}
}
It gives follwing exceptions.While when i cal that t.txt file from IE5.0 It works but here it gives exception.Please Help.
javax.microedition.io.ConnectionNotFoundExceptionjavax.microedition.io.ConnectionNotFoundExceptionat com.sun.cldc.io.j2me.socket.Protocol.openPrim(+7)at com.sun.midp.io.InternalConnector.openPrim(+180)at com.sun.midp.io.InternalConnector.openInternal(+20)at com.sun.midp.io.j2me.http.StreamConnectionPool.createStreamConnectionElement(+140)at com.sun.midp.io.j2me.http.StreamConnectionPool.getConnection(+121)at com.sun.midp.io.j2me.http.Protocol.connect(+64)at com.sun.midp.io.j2me.http.Protocol.sendRequest(+90)at com.sun.midp.io.j2me.http.Protocol.openInputStream(+48)at FirstExample.getViaStreamConnection(+30)at FirstExample.startApp(+8)at javax.microedition.midlet.MIDletProxy.startApp(+7)at com.sun.midp.midlet.Scheduler.schedule(+225)at com.sun.midp.dev.DevMIDletSuiteImpl.schedule(+7)at com.sun.midp.Main.runLocalClass(+20)at com.sun.midp.Main.main(+68)Execution completed successfullyimport java.io.*;