@Test public void exportBeans() throws IOException { importBeans(); List<CsvBean> list = processor.exportBeans(CsvBean.class, testBeansPath); for (CsvBean bean : list) { logger.info(bean); } }
@Override public <T> List<T> exportBeans(Class<T> clazz, String filePath) throws IOException { List<FieldDesc> list = processeCache.getFieldDescs(clazz); Assert.assertTrue(CollectionUtil.isNotEmpty(list), "FieldDesc is not empty"); List<String> lines = ReaderUtil.readLinesAndClose(filePath, Charset.forName(GBK)); List<String> titles = processeCache.getTitles(clazz); if (CollectionUtil.isEmpty(titles)) { return linesToList(clazz, list, lines); } lines.remove(0); return linesToList(clazz, list, lines); }
CsvProcessor implements FileProcessor { @Override public <T> List<T> exportBeans(Class<T> clazz, String filePath) throws IOException { List<FieldDesc> list = processeCache.getFieldDescs(clazz); Assert.assertTrue(CollectionUtil.isNotEmpty(list), "FieldDesc is not empty"); List<String> lines = ReaderUtil.readLinesAndClose(filePath, Charset.forName(GBK)); List<String> titles = processeCache.getTitles(clazz); if (CollectionUtil.isEmpty(titles)) { return linesToList(clazz, list, lines); } lines.remove(0); return linesToList(clazz, list, lines); } }
CsvProcessor implements FileProcessor { @Override public <T> List<T> exportBeans(Class<T> clazz, String filePath) throws IOException { List<FieldDesc> list = processeCache.getFieldDescs(clazz); Assert.assertTrue(CollectionUtil.isNotEmpty(list), "FieldDesc is not empty"); List<String> lines = ReaderUtil.readLinesAndClose(filePath, Charset.forName(GBK)); List<String> titles = processeCache.getTitles(clazz); if (CollectionUtil.isEmpty(titles)) { return linesToList(clazz, list, lines); } lines.remove(0); return linesToList(clazz, list, lines); }  }
CsvProcessor implements FileProcessor { @Override public <T> List<T> exportBeans(Class<T> clazz, String filePath) throws IOException { List<FieldDesc> list = processeCache.getFieldDescs(clazz); Assert.assertTrue(CollectionUtil.isNotEmpty(list), "FieldDesc is not empty"); List<String> lines = ReaderUtil.readLinesAndClose(filePath, Charset.forName(GBK)); List<String> titles = processeCache.getTitles(clazz); if (CollectionUtil.isEmpty(titles)) { return linesToList(clazz, list, lines); } lines.remove(0); return linesToList(clazz, list, lines); }  @Override void importBean(Object bean, String filePath); @Override void importBeans(Class<?> clazz, Object[] beans, String filePath); @Override void importBeans(String[] contents, String filePath); @Override void importBeans(List<String> contents, String filePath); @Override T exportBean(Class<T> clazz, String filePath); @Override List<T> exportBeans(Class<T> clazz, String filePath); @Override void importBeans(String[] headers, Class<?> clazz, Object[] beans, String filePath); @Override void importBeans(ListMap<String, String> headers, Class<?> clazz, Object[] beans, String filePath); @Override List<String> collectData(FileBeanInfo beanInfo); @Override void importBeans(FileBeanInfo beanInfo, String filePath); @Override ByteArray toByteArray(FileBeanInfo beanInfo); @Override ByteArray toByteArray(List<String> contents); }
CsvProcessor implements FileProcessor { @Override public <T> List<T> exportBeans(Class<T> clazz, String filePath) throws IOException { List<FieldDesc> list = processeCache.getFieldDescs(clazz); Assert.assertTrue(CollectionUtil.isNotEmpty(list), "FieldDesc is not empty"); List<String> lines = ReaderUtil.readLinesAndClose(filePath, Charset.forName(GBK)); List<String> titles = processeCache.getTitles(clazz); if (CollectionUtil.isEmpty(titles)) { return linesToList(clazz, list, lines); } lines.remove(0); return linesToList(clazz, list, lines); }  @Override void importBean(Object bean, String filePath); @Override void importBeans(Class<?> clazz, Object[] beans, String filePath); @Override void importBeans(String[] contents, String filePath); @Override void importBeans(List<String> contents, String filePath); @Override T exportBean(Class<T> clazz, String filePath); @Override List<T> exportBeans(Class<T> clazz, String filePath); @Override void importBeans(String[] headers, Class<?> clazz, Object[] beans, String filePath); @Override void importBeans(ListMap<String, String> headers, Class<?> clazz, Object[] beans, String filePath); @Override List<String> collectData(FileBeanInfo beanInfo); @Override void importBeans(FileBeanInfo beanInfo, String filePath); @Override ByteArray toByteArray(FileBeanInfo beanInfo); @Override ByteArray toByteArray(List<String> contents);  }