mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-08-18 20:38:02 +08:00
fix bug
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package cn.hutool.core.io;
|
||||
|
||||
import cn.hutool.core.io.resource.ResourceUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -10,14 +11,22 @@ import java.io.IOException;
|
||||
public class IoUtilTest {
|
||||
|
||||
@Test
|
||||
public void readBytesTest(){
|
||||
public void readBytesTest() {
|
||||
final byte[] bytes = IoUtil.readBytes(ResourceUtil.getStream("hutool.jpg"));
|
||||
Assert.assertEquals(22807, bytes.length);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readLinesTest(){
|
||||
try(BufferedReader reader = ResourceUtil.getUtf8Reader("test_lines.csv");){
|
||||
public void readBytesWithLengthTest() {
|
||||
// 读取固定长度
|
||||
final int limit = RandomUtil.randomInt(22807);
|
||||
final byte[] bytes = IoUtil.readBytes(ResourceUtil.getStream("hutool.jpg"), limit);
|
||||
Assert.assertEquals(limit, bytes.length);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readLinesTest() {
|
||||
try (BufferedReader reader = ResourceUtil.getUtf8Reader("test_lines.csv");) {
|
||||
IoUtil.readLines(reader, (LineHandler) Assert::assertNotNull);
|
||||
} catch (IOException e) {
|
||||
throw new IORuntimeException(e);
|
||||
|
Reference in New Issue
Block a user