FileOutputStream fos=new FileOutputStream(img_path+savename);savename若是中文就乱码了,怎么办?

2025-01-07 20:16:16
推荐回答(2个)
回答1:

pathEncoder = URLEncoder.encode(img_path+savename, "UTF-8"); //用这个
如果还不行 就用
OutputStreamWriter osw = null;
osw = new OutputStreamWriter(new FileOutputStream(img_path+savename), "UTF-8");

回答2:

要转码,例:
String str = new String(savename
.getBytes("GB2312"), "gbk");