logo资料库

成功解决 Android 下载中文文件名.docx

第1页 / 共1页
资料共1页,全文预览结束
成功解决 Android 下载中文文件名 2011-04-22 17:19 1、tomcat6.x 服务器 2、android 虚拟器下载文件 如下载服务器上文件: 测试.MP3 下载路径:http://192.168.1.110:8080/mp3/测试.mp3 解决办法: 1.先在设置服务器编码:找到 Tomcat 安装目录下的 server.xml 文件(Tomcat 6.0\conf\server.xml)。设置编码为 UTF-8 2. android 中代码为: String UrlStr = "http://192.168.1.110:8080/mp3/"+URLEncoder.encode(测 试.mp3,"UTF-8"); try { URL url = new URL(UrlStr); HttpURLConnection urlConn = (HttpURLConnection) url.openConnection(); inputStream =urlConn.getInputStream(); } catch (Exception e) { e.printStackTrace(); } 这样就成能成功地下载到服务器上的中文文件名的文件了。
分享到:
收藏