Try this code. I have not tried it. I think it's better.
private void httpConnection(
String url){
HttpConnection httpConnection = null;
DataInputStream din = null;
StringBuffer sb = new StringBuffer();
try{
httpConnection = (HttpConnection) Connector.open(url);
conn.setRequestMethod( HttpConnection.GET );
conn.setRequestProperty("User-Agent", "Profile/MIDP-1.0 Configuration/CLDC-1.0");
int ch;
din = httpConnection.openDataInputStream();
int ch = din.read();
while ( ch != -1 ) {
sb.append( (char)ch );
ch = din.read();
}
}
catch (IOException ex) {
System.out.println(ex.toString());
}
catch (Exception ex) {
System.out.println(e.toString());
}
finally {
din.close();
httpConnection.close();
}
String sResult = sb.toString();
this.append(sResult);
}
OULD NADIF