【发布时间】:2014-08-17 04:17:23
【问题描述】:
我想从android向服务器发送大字符串,我可以用这个方法发送小字符串
InputStream is;
String name = "Name";
String str = "LargeString";
ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("name", name));
nameValuePairs.add(new BasicNameValuePair("encoded", str));
try {
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new
HttpPost("http://192.168.1.101/test/insert.php");
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
is = (InputStream) entity.getContent();
} catch (Exception e) {
Log.e("log_tag", "Error in http connection " + e.toString());
}
使用此代码,我可以发送小字符串但不能发送大字符串。 请帮帮我。
谢谢。
【问题讨论】:
-
在帖子中你可以发送大字符串,你有什么错误吗?
-
什么是错误,显示logcat信息
-
此链接将帮助您 [如何使用 Android 通过 Request 发送 JSON 对象?] stackoverflow.com/questions/3027066/…
-
没有错误显示,但是当我发送小字符串时它可以工作,但大字符串不起作用
-
我尝试发送视频编码字符串