mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
add methods
This commit is contained in:
@@ -259,10 +259,22 @@ public final class CsvWriter implements Closeable, Flushable, Serializable {
|
|||||||
* @param properties 可选属性列表,空表示全部属性
|
* @param properties 可选属性列表,空表示全部属性
|
||||||
* @return this
|
* @return this
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("resource")
|
|
||||||
public CsvWriter writeBeans(final Iterable<?> beans, final String... properties) {
|
public CsvWriter writeBeans(final Iterable<?> beans, final String... properties) {
|
||||||
|
return writeBeans(beans, true, properties);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将一个Bean集合写出到Writer,并自动生成表头
|
||||||
|
*
|
||||||
|
* @param beans Bean集合
|
||||||
|
* @param writeHeaderLine 是否写出表头,即Bean的字段名称列表作为首行
|
||||||
|
* @param properties 可选属性列表,空表示全部属性
|
||||||
|
* @return this
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("resource")
|
||||||
|
public CsvWriter writeBeans(final Iterable<?> beans, final boolean writeHeaderLine, final String... properties) {
|
||||||
if (CollUtil.isNotEmpty(beans)) {
|
if (CollUtil.isNotEmpty(beans)) {
|
||||||
boolean isFirst = true;
|
boolean isFirst = writeHeaderLine;
|
||||||
Map<String, Object> map;
|
Map<String, Object> map;
|
||||||
for (final Object bean : beans) {
|
for (final Object bean : beans) {
|
||||||
map = BeanUtil.beanToMap(bean, properties);
|
map = BeanUtil.beanToMap(bean, properties);
|
||||||
|
Reference in New Issue
Block a user