package cn.edu.ncu.xjx.web.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.encode(filename.getBytes("utf-8")) + "?=";
} else {
// 其它浏览器
filename = URLEncoder.encode(filename, "utf-8");
}
return filename;
}
}
DownLoadUtils工具类
最新推荐文章于 2022-07-17 10:08:41 发布