import java.io.IOException; import java.io.UnsupportedEncodingException; public class ConvertUnico

本文提供了一个 Java 示例程序,演示如何将 Unicode 编码的字符串转换为 GB2312 编码。通过具体的代码实现,读者可以了解不同字符集之间的转换方法。
import java.io.IOException;
import java.io.UnsupportedEncodingException;




public class ConvertUnicode {
public static void main(String arg[]) throws IOException{
String str1 = "\u6237\u767B";
String str2 = new String(str1.getBytes("GB2312"));
System.out.println(str2);
}
}
package org.enroll.controller; import org.enroll.service.interfaces.IExcelService; import org.enroll.utils.JsonResponse; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; @Controller @RequestMapping("/file") public class FileController { @Autowired IExcelService excelService; @ResponseBody @RequestMapping("/uploadMajor") public JsonResponse uploadMajorExcel(MultipartFile file) throws IOException { excelService.ReadMajorExcel(file); return new JsonResponse(JsonResponse.OK,null,null); } @ResponseBody @RequestMapping("/uploadStudent") public JsonResponse uploadStudentExcel(MultipartFile file) throws IOException { excelService.ReadStudentExcel(file); return new JsonResponse(JsonResponse.OK,null,null); } @RequestMapping("/exportResult") public void export(HttpServletResponse response) throws IOException { response.setContentType("application/vnd.ms-excel"); response.setCharacterEncoding("utf-8"); String fileName = URLEncoder.encode("录取结果", "UTF-8").replaceAll("\\+", "%20"); response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx"); excelService.doExport(response.getOutputStream()); } @RequestMapping("/exportExit") public void exportExit(HttpServletResponse response) throws IOException { response.setContentType("application/vnd.ms-excel"); response.setCharacterEncoding("utf-8"); String fileName = URLEncoder.encode("退档结果", "UTF-8").replaceAll("\\+", "%20"); response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx"); excelService.exportExitStudent(response.getOutputStream()); } } 简单易懂说明代码作用
06-27
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值