### Question:
CsvUtil { public static void writeCsvFile(HttpServletResponse response, HttpServletRequest request, String filename, String[] title, List<String[]> bodyList) { response.setContentType("application/octet-stream;charset=GBK"); String fileName = FileUtilies.getFileName(filename, request); response.setHeader("Content-Disposition", "attachment; filename=" + fileName + ".csv"); try (CSVWriter writer = new CSVWriter(response.getWriter())) { write(writer, title, bodyList); } catch (IOException e) { throw new RuntimeException("write csv file of response fail ", e); } }  static void writeCsvFile(HttpServletResponse response, HttpServletRequest request,
                                    String filename, String[] title, List<String[]> bodyList); static void writeCsvFile(HttpServletResponse response, HttpServletRequest request,
			String filename, String[] title, List<T> objs, Function<T, String[]> function); static void writeCsvFile(String filename, String[] title, List<String[]> bodyList); static void writeCsvFile(String filename, String[] title, List<T> objs,
										Function<T, String[]> function);  }### Answer:
@Test public void testStringArrayWriteCsvFile() { String[] title = {"id" , "name"}; List<String[]> bodyList = new ArrayList<>(); String[] data = new String[2]; data[0] = "1"; data[1] = "张三"; bodyList.add(data); data = new String[2]; data[0] = "2"; data[1] = "李四"; bodyList.add(data); CsvUtil.writeCsvFile(fileName, title, bodyList); }
@Test public void testObjectWriteCsvFile() { String[] title = {"id" , "name"}; List<User> objs = new ArrayList<>(); User user = new User(); user.setId(1); user.setName("张三"); objs.add(user); user = new User(); user.setId(2); user.setName("李四"); objs.add(user); CsvUtil.writeCsvFile(fileName, title, objs, t -> { String[] bodyList = new String[2]; bodyList[0] = t.getId() + ""; bodyList[1] = t.getName(); return bodyList; }); }