u014229133
09123
2017-08-05 11:37

ubuntu 14.04导出图片名称部分汉字乱码

  • ubuntu
  • 乱码

例如:司薇等汉字,
代码如下:
filename = new String(filename.getBytes("utf-8"),"UTF-8");
//构造URL
URL url = new URL(replace);
//打开连接
URLConnection conn = url.openConnection();
conn.setRequestProperty("User-Agent", "Mozilla/4.0(compatible;MSIE 5.0;Windows NT;DigExt)");
//输入流
is = conn.getInputStream();
//1k的数据缓冲
byte[] bs = new byte[1024];
int len;
//输出的文件流
os = new FileOutputStream(filename,true);
//开始读取
while((len = is.read(bs)) != -1){
os.write(bs,0,len);
}

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答