String fileName = "导出名称.txt";
try {
getResponse().setContentType("application/x-download");
getResponse().setHeader(
"Content-Disposition",
"attachment;filename="
+ new String(fileName.getBytes("gb2312"),
"ISO8859-1")); //处理下载名称编码格式
BufferedWriter fw;
fw = new BufferedWriter(new OutputStreamWriter(getResponse()
.getOutputStream(), "utf-8")); //设置写内容的编码格式
for (StopWord stopWord : this.stopWordService.listAll()) {
fw.write(stopWord.getName()); // 写内容
fw.newLine();// 断行
}
fw.flush();
fw.close();
} catch (IOException e) {
e.printStackTrace();
}