Skip to content

Instantly share code, notes, and snippets.

@criccomini
Created September 23, 2012 22:52
Show Gist options
  • Save criccomini/3773338 to your computer and use it in GitHub Desktop.
Save criccomini/3773338 to your computer and use it in GitHub Desktop.
BlackBerry HTTP Client
import java.io.InputStream;
import javax.microedition.io.Connector;
import javax.microedition.io.StreamConnection;
public class HTTPClient {
public static String getPage(String url) {
String response = "";
try {
StreamConnection s = (StreamConnection)Connector.open(url);
InputStream input = s.openInputStream();
byte[] data = new byte[256];
int len = 0;
StringBuffer raw = new StringBuffer();
while( -1 != (len = input.read(data))) {
raw.append(new String(data, 0, len));
}
response = raw.toString();
input.close();
s.close();
} catch(Exception e) { }
return response;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment