好吧,问题已解决,用那个“难道要”还真解决了。
String videoIDStr = videoID.toString();
videoIDStr = "0000" + videoID;
String fileName = "kcjy" + videoIDStr.substring(videoIDStr.length() - 4) + ".html";
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
response.setCharacterEncoding("UTF-8");
PrintWriter out = response.getWriter();
try {
if (out != null) {
byte[] bomStrByteArr = new byte[]{(byte)0xef,(byte)0xbb,(byte)0xbf};
String bomStr = new String(bomStrByteArr, "UTF-8");
out.write(bomStr);
out.write(sb.toString());
}
手动写入BOM的头三个字节,下载下来的文件还真就成UTF-8+BOM格式了
String videoIDStr = videoID.toString();
videoIDStr = "0000" + videoID;
String fileName = "kcjy" + videoIDStr.substring(videoIDStr.length() - 4) + ".html";
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
response.setCharacterEncoding("UTF-8");
PrintWriter out = response.getWriter();
try {
if (out != null) {
byte[] bomStrByteArr = new byte[]{(byte)0xef,(byte)0xbb,(byte)0xbf};
String bomStr = new String(bomStrByteArr, "UTF-8");
out.write(bomStr);
out.write(sb.toString());
}
手动写入BOM的头三个字节,下载下来的文件还真就成UTF-8+BOM格式了