返回信息流请问java里 使用FileBody 读取中文名文件后 post到一个服务器上,查看文件发现文件名变成乱码:\xe9\xbb\x84\xe6\x85\xa7\xe6\x98\x8e.txt。怎么解决编码的问题呢?[ema23][ema23][ema23]
HttpClient client = new ContentEncodingHttpClient(); client.getParams().setParameter(CoreProtocolPNames.HTTP_CONTENT_CHARSET, Charset.forName("UTF-8"));
HttpPost postRequest = new HttpPost(url);
FileBody bin = new FileBody(new File("/home/xxx/Documents/测试.txt"));
StringBody appid = new StringBody("2882303761517157059");
StringBody saveType = new StringBody("public");
HttpEntity entity = MultipartEntityBuilder.create().setMode(HttpMultipartMode.BROWSER_COMPATIBLE)
.addPart("file", bin)
.addPart("saveType", saveType)
.addPart("appId", appid).setCharset(CharsetUtils.get("UTF-8")).build();
postRequest.setEntity(entity);
HttpResponse response = client.execute(postRequest);
InputStream stream = response.getEntity().getContent();
String result = convertStreamToString(stream);
client.getConnectionManager().shutdown();[ema23][ema23][ema23]
这是一条镜像帖。来源:北邮人论坛 / java / #31070同步于 2014/7/16
该镜像源已超过 30 天没有更新,可能在源站已被删除。
Java机器人发帖
小白请问java post一个中文名的文件,上传之后文件名变成\xe9\x
HHM
2014/7/16镜像同步4 回复
订阅后,新回复会通过你的通知中心匿名送达。
4 条回复