mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
fix csv
This commit is contained in:
parent
e1fe54c59d
commit
1ddc01453f
@ -6,7 +6,11 @@
|
|||||||
## 4.6.9
|
## 4.6.9
|
||||||
|
|
||||||
### 新特性
|
### 新特性
|
||||||
|
* 【all】 修复注释中的错别字(issue#I12XE6@Gitee)
|
||||||
|
* 【core】 CsvWriter支持其它类型的参数(issue#I12XE3@Gitee)
|
||||||
|
|
||||||
### Bug修复
|
### Bug修复
|
||||||
|
* 【all】 修复阶乘计算错误bug(issue#I12XE4@Gitee)
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -233,7 +233,7 @@ public class Convert {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 转换为Integer数组<br>
|
* 转换为Integer数组<br>
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
|
@ -11,6 +11,7 @@ import java.nio.charset.Charset;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.convert.Convert;
|
||||||
import cn.hutool.core.io.FileUtil;
|
import cn.hutool.core.io.FileUtil;
|
||||||
import cn.hutool.core.io.IORuntimeException;
|
import cn.hutool.core.io.IORuntimeException;
|
||||||
import cn.hutool.core.io.IoUtil;
|
import cn.hutool.core.io.IoUtil;
|
||||||
@ -183,14 +184,14 @@ public final class CsvWriter implements Closeable, Flushable, Serializable {
|
|||||||
/**
|
/**
|
||||||
* 将多行写出到Writer
|
* 将多行写出到Writer
|
||||||
*
|
*
|
||||||
* @param lines 多行数据
|
* @param lines 多行数据,每行数据可以是集合或者数组
|
||||||
* @return this
|
* @return this
|
||||||
* @throws IORuntimeException IO异常
|
* @throws IORuntimeException IO异常
|
||||||
*/
|
*/
|
||||||
public CsvWriter write(Collection<String[]> lines) throws IORuntimeException {
|
public CsvWriter write(Collection<?> lines) throws IORuntimeException {
|
||||||
if (CollUtil.isNotEmpty(lines)) {
|
if (CollUtil.isNotEmpty(lines)) {
|
||||||
for (final String[] values : lines) {
|
for (Object values : lines) {
|
||||||
appendLine(values);
|
appendLine(Convert.toStrArray(values));
|
||||||
}
|
}
|
||||||
flush();
|
flush();
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ import java.util.Set;
|
|||||||
|
|
||||||
import cn.hutool.core.exceptions.UtilException;
|
import cn.hutool.core.exceptions.UtilException;
|
||||||
import cn.hutool.core.lang.Assert;
|
import cn.hutool.core.lang.Assert;
|
||||||
|
import cn.hutool.core.lang.Console;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数字工具类<br>
|
* 数字工具类<br>
|
||||||
@ -1382,17 +1383,17 @@ public class NumberUtil {
|
|||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @param start 阶乘起始
|
* @param start 阶乘起始
|
||||||
* @param end 阶乘结束
|
* @param end 阶乘结束,必须小于起始
|
||||||
* @return 结果
|
* @return 结果
|
||||||
* @since 4.1.0
|
* @since 4.1.0
|
||||||
*/
|
*/
|
||||||
public static long factorial(long start, long end) {
|
public static long factorial(long start, long end) {
|
||||||
|
if (0L == start || start == end) {
|
||||||
|
return 1L;
|
||||||
|
}
|
||||||
if (start < end) {
|
if (start < end) {
|
||||||
return 0L;
|
return 0L;
|
||||||
}
|
}
|
||||||
if (start == end) {
|
|
||||||
return 1L;
|
|
||||||
}
|
|
||||||
return start * factorial(start - 1, end);
|
return start * factorial(start - 1, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,13 +188,13 @@ public class NumberUtilTest {
|
|||||||
BigDecimal bigDecimal = NumberUtil.toBigDecimal(a);
|
BigDecimal bigDecimal = NumberUtil.toBigDecimal(a);
|
||||||
Assert.assertEquals("3.14", bigDecimal.toString());
|
Assert.assertEquals("3.14", bigDecimal.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void maxTest() {
|
public void maxTest() {
|
||||||
int max = NumberUtil.max(new int[]{5,4,3,6,1});
|
int max = NumberUtil.max(new int[]{5,4,3,6,1});
|
||||||
Assert.assertEquals(6, max);
|
Assert.assertEquals(6, max);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void minTest() {
|
public void minTest() {
|
||||||
int min = NumberUtil.min(new int[]{5,4,3,6,1});
|
int min = NumberUtil.min(new int[]{5,4,3,6,1});
|
||||||
@ -232,4 +232,15 @@ public class NumberUtilTest {
|
|||||||
long v6 = NumberUtil.parseLong("22.4D");
|
long v6 = NumberUtil.parseLong("22.4D");
|
||||||
Assert.assertEquals(22L, v6);
|
Assert.assertEquals(22L, v6);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void factorialTest(){
|
||||||
|
long factorial = NumberUtil.factorial(0);
|
||||||
|
Assert.assertEquals(1, factorial);
|
||||||
|
|
||||||
|
factorial = NumberUtil.factorial(5, 0);
|
||||||
|
Assert.assertEquals(120, factorial);
|
||||||
|
factorial = NumberUtil.factorial(5, 1);
|
||||||
|
Assert.assertEquals(120, factorial);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user