package cn.itcast.utils;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Base64;
public class DownLoadUtils {
public static String getFileName(String agent, String filename) throws UnsupportedEncodingException {
if (agent.contains("MSIE")) {
// IE浏览器
filename = URLEncoder.encode(filename, "utf-8");
filename = filename.replace("+", " ");
} else if (agent.contains("Firefox")) {
// 火狐浏览器
Base64.Encoder encoder = Base64.getEncoder();
filename = "=?utf-8?B?" +encoder.encodeToString(filename.getBytes("utf-8")) + "?=";
} else {
// 其它浏览器
filename = URLEncoder.encode(filename, "utf-8");
}
return filename;
}
}
不报错的downLoadUtilse工具类
最新推荐文章于 2024-08-15 14:47:41 发布
关键词由CSDN通过智能技术生成