Wednesday, July 29, 2009

BackBerry GET Request to the Server

public static String getHttpResponce (String URL) {
try {
HttpConnection httpConnection = (HttpConnection) Connector.open(URL);
httpConnection.setRequestMethod(HttpConnection.GET);
InputStream inputStream = httpConnection.openInputStream();
StringBuffer sb = new StringBuffer();
int C;
while( -1 != (C = inputStream.read())) 
{
sb.append((char)C);
}
return sb.toString();

} catch (Exception e) {
return "-1";
}
}
Post a Comment