i'm developing J2ME.
Could you mind helping me to find out whats wrong with this code:
HttpConnection c = null;
try {
c = (HttpConnection)Connector.open("http://www.mysite.com",Connector.READ_WRITE, true);
c.setRequestMethod(HttpConnection.GET); //default
is = c.openInputStream(); // transition to connected!
int ch = 0;
for(int ccnt=0; ccnt < 150; ccnt++) { // get the title.
ch = is.read();
if (ch == -1){
break;
}
sb.append((char)ch);
}
}
catch (IOException x){
x.printStackTrace();
}
finally{
try {
is.close();
c.close();
} catch (IOException x){
x.printStackTrace();
}
}
System.out.println(sb.toString());
i'm trying open website through my app, thanks before :)
To open a URL in J2ME you do the following in a non-system thread: