I am creating connection through httpclient. But blackberry does not support java httpclient class. Please send me code to create connection through httpclient to server.
A:
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;
}
}
Andrei Bularca
2010-10-06 12:56:03
I think http://hc.apache.org/httpclient-3.x/ is what the OP meant.
Michael Donohue
2010-10-06 16:24:19