【发布时间】:2011-09-13 05:41:10
【问题描述】:
我正在使用 HttpPost 建立网络服务连接。我能够检索除 unicode 数据之外的数据。如果我想显示这些数据,它们看起来会有所不同。我正在研究希伯来语。
private static String callRestWebService(
List<BasicNameValuePair> nameValuePairs, int action, String url) {
String result = null;
int TIMEOUT_MILLISEC = 10000; // = 10 seconds
HttpParams httpParams = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(httpParams, TIMEOUT_MILLISEC);
HttpConnectionParams.setSoTimeout(httpParams, TIMEOUT_MILLISEC);
HttpClient httpclient = new DefaultHttpClient(httpParams);
HttpPost request = new HttpPost(url);
try {
request.setEntity(new UrlEncodedFormEntity(nameValuePairs));
ResponseHandler<String> handler = new BasicResponseHandler();
result = httpclient.execute(request, handler);
parse(result, action);
result = null;
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
httpclient.getConnectionManager().shutdown();
return result;
}
【问题讨论】: