mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix code
This commit is contained in:
@@ -280,6 +280,7 @@ public class StrUtilTest {
|
||||
Assert.assertEquals("ghigh", pre);
|
||||
}
|
||||
|
||||
@SuppressWarnings("SimplifiableAssertion")
|
||||
@Test
|
||||
public void subPreTest() {
|
||||
Assert.assertEquals(StrUtil.subPre(null, 3), null);
|
||||
|
@@ -216,7 +216,7 @@ public class ArrayUtilTest {
|
||||
final String[] a = {"1", "2", "3", "4"};
|
||||
final String[] b = {"a", "b", "c"};
|
||||
|
||||
// 在-1位置插入,相当于在3位置插入
|
||||
// 在-1的位置插入,相当于在3的位置插入
|
||||
String[] result = ArrayUtil.insert(a, -1, b);
|
||||
Assert.assertArrayEquals(new String[]{"1", "2", "3", "a", "b", "c", "4"}, result);
|
||||
|
||||
@@ -232,7 +232,7 @@ public class ArrayUtilTest {
|
||||
result = ArrayUtil.insert(a, 4, b);
|
||||
Assert.assertArrayEquals(new String[]{"1", "2", "3", "4", "a", "b", "c"}, result);
|
||||
|
||||
// 在第5个位置插入,由于数组长度为4,因此补null
|
||||
// 在第5个位置插入,由于数组长度为4,因此补充null
|
||||
result = ArrayUtil.insert(a, 5, b);
|
||||
Assert.assertArrayEquals(new String[]{"1", "2", "3", "4", null, "a", "b", "c"}, result);
|
||||
}
|
||||
@@ -472,7 +472,7 @@ public class ArrayUtilTest {
|
||||
final String[] a = {"1", "2", "3", "4"};
|
||||
final String[] b = {"a", "b", "c"};
|
||||
|
||||
// 在小于0的位置,-1位置插入,返回b+a,新数组
|
||||
// 在小于0的位置,-1的位置插入,返回b+a,新数组
|
||||
String[] result = ArrayUtil.replace(a, -1, b);
|
||||
Assert.assertArrayEquals(new String[]{"a", "b", "c", "1", "2", "3", "4"}, result);
|
||||
|
||||
|
@@ -2,8 +2,8 @@ package cn.hutool.core.util;
|
||||
|
||||
import cn.hutool.core.compress.ZipReader;
|
||||
import cn.hutool.core.compress.ZipUtil;
|
||||
import cn.hutool.core.io.file.FileUtil;
|
||||
import cn.hutool.core.io.IORuntimeException;
|
||||
import cn.hutool.core.io.file.FileUtil;
|
||||
import cn.hutool.core.lang.Console;
|
||||
import cn.hutool.core.text.StrUtil;
|
||||
import org.junit.Assert;
|
||||
@@ -11,11 +11,12 @@ import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.zip.ZipFile;
|
||||
@@ -156,7 +157,7 @@ public class ZipUtilTest {
|
||||
//https://github.com/dromara/hutool/issues/944
|
||||
final String dir = "d:/test";
|
||||
final String zip = "d:/test.zip";
|
||||
try (final OutputStream out = new FileOutputStream(zip)){
|
||||
try (final OutputStream out = Files.newOutputStream(Paths.get(zip))){
|
||||
//实际应用中, out 为 HttpServletResponse.getOutputStream
|
||||
ZipUtil.zip(out, Charset.defaultCharset(), false, null, new File(dir));
|
||||
} catch (final IOException e) {
|
||||
|
Reference in New Issue
Block a user