mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
add config
This commit is contained in:
parent
f08ae8cf7d
commit
a7817ab5b0
@ -3,9 +3,11 @@
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
|
||||
# 5.7.13 (2021-09-10)
|
||||
# 5.7.13 (2021-09-11)
|
||||
|
||||
### 🐣新特性
|
||||
* 【core 】 CsvReadConfig增加trimField选项(issue#I49M0C@Gitee)
|
||||
*
|
||||
### 🐞Bug修复
|
||||
* 【core 】 修复FuncKey函数无效问题
|
||||
* 【core 】 修复ImgUtil.copyImage读取网络URL后宽高报错问题(issue#1821@Github)
|
||||
|
@ -332,6 +332,10 @@ public final class CsvParser implements Closeable, Serializable {
|
||||
|
||||
// 忽略多余引号后的换行符
|
||||
field = StrUtil.trim(field, 1, (c-> c == CharUtil.LF || c == CharUtil.CR));
|
||||
if(this.config.trimField){
|
||||
// issue#I49M0C@Gitee
|
||||
field = StrUtil.trim(field);
|
||||
}
|
||||
|
||||
field = StrUtil.unWrap(field, textDelimiter);
|
||||
field = StrUtil.replace(field, "" + textDelimiter + textDelimiter, textDelimiter + "");
|
||||
|
@ -21,6 +21,8 @@ public class CsvReadConfig extends CsvConfig<CsvReadConfig> implements Serializa
|
||||
protected long beginLineNo;
|
||||
/** 结束的行(包括),此处为原始文件行号 */
|
||||
protected long endLineNo = Long.MAX_VALUE-1;
|
||||
/** 每个字段是否去除两边空白符 */
|
||||
protected boolean trimField;
|
||||
|
||||
/**
|
||||
* 默认配置
|
||||
@ -87,4 +89,17 @@ public class CsvReadConfig extends CsvConfig<CsvReadConfig> implements Serializa
|
||||
this.endLineNo = endLineNo;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置每个字段是否去除两边空白符<br>
|
||||
* 如果字段以{@link #textDelimiter}包围,则保留两边空格
|
||||
*
|
||||
* @param trimField 去除两边空白符
|
||||
* @return this
|
||||
* @since 5.7.13
|
||||
*/
|
||||
public CsvReadConfig setTrimField(boolean trimField) {
|
||||
this.trimField = trimField;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user