核心代码
import org.apache.commons.lang3.StringUtils;
import sun.misc.BASE64Encoder;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
/**
* @program: svc
* @description:
* @author: tangweiming
* @create: 2019/6/30 14:08
*/
public class FileDownloadUtil {
/**
* 下载文件
* @param originalFileName :下载文件的原始文件名
* @param file :下载的文件
* @param response :相应对象
*/
public static void downloadFile(String originalFileName, File file, HttpServletResponse response, HttpServletRequest request) {
// 数据校验
checkParam(originalFileName,file);
//相应头的处理