mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix code
This commit is contained in:
@@ -28,7 +28,7 @@ public interface AnnotationMapping<T extends Annotation> extends Annotation {
|
||||
T getAnnotation();
|
||||
|
||||
/**
|
||||
* 根据当前映射对象,通过动态代理生成一个类型与被包装注解对象一致的合成注解,该注解相对原生注解:
|
||||
* 根据当前映射对象,通过动态代理生成一个类型与被包装注解对象一致地合成注解,该注解相对原生注解:
|
||||
* <ul>
|
||||
* <li>支持同注解内通过{@link Alias}构建的别名机制;</li>
|
||||
* <li>支持子注解对元注解的同名同类型属性覆盖机制;</li>
|
||||
|
@@ -73,7 +73,7 @@ public class BetweenFormatter implements Serializable {
|
||||
final int level = this.level.ordinal();
|
||||
int levelCount = 0;
|
||||
|
||||
if (isLevelCountValid(levelCount) && 0 != day && level >= Level.DAY.ordinal()) {
|
||||
if (isLevelCountValid(levelCount) && 0 != day) {
|
||||
sb.append(day).append(Level.DAY.name);
|
||||
levelCount++;
|
||||
}
|
||||
|
@@ -15,6 +15,7 @@ import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -246,7 +247,7 @@ public class FileReader extends FileWrapper {
|
||||
*/
|
||||
public BufferedInputStream getInputStream() throws IORuntimeException {
|
||||
try {
|
||||
return new BufferedInputStream(new FileInputStream(this.file));
|
||||
return new BufferedInputStream(Files.newInputStream(this.file.toPath()));
|
||||
} catch (final IOException e) {
|
||||
throw new IORuntimeException(e);
|
||||
}
|
||||
|
@@ -123,6 +123,7 @@ public class ResourceUtil {
|
||||
*
|
||||
* @param resource 资源(相对Classpath的路径)
|
||||
* @return 资源URL
|
||||
* @throws IORuntimeException IO异常
|
||||
*/
|
||||
public static URL getResourceUrl(final String resource) throws IORuntimeException {
|
||||
return getResourceUrl(resource, null);
|
||||
|
@@ -24,7 +24,7 @@ import java.util.function.Predicate;
|
||||
* </table>
|
||||
*
|
||||
* <p>空区间</p>
|
||||
* <p>根据数学定义,当区间中无任何实数时,认为该区间代表的集合为空集,
|
||||
* <p>根据数学定义,当区间中无任何实数时,认为该区间 代表的集合为空集,
|
||||
* 用户可通过{@link #isEmpty}确认当前实例是否为空区间。<br>
|
||||
* 若实例上界<em>a</em>,下界为<em>b</em>,则当实例满足下述任意条件时,认为其为一个空区间:
|
||||
* <ul>
|
||||
|
@@ -254,6 +254,7 @@ public interface TerminableWrappedStream<T, S extends TerminableWrappedStream<T,
|
||||
* @param predicate 断言
|
||||
* @return 与给定断言匹配的第一个元素的下标,如果不存在则返回-1
|
||||
*/
|
||||
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||
default int findFirstIdx(final Predicate<? super T> predicate) {
|
||||
Objects.requireNonNull(predicate);
|
||||
if (isParallel()) {
|
||||
@@ -263,7 +264,7 @@ public interface TerminableWrappedStream<T, S extends TerminableWrappedStream<T,
|
||||
unwrap().filter(e -> {
|
||||
index.increment();
|
||||
return predicate.test(e);
|
||||
}).findFirst();
|
||||
}).findFirst();// 此处只做计数,不需要值
|
||||
return index.get();
|
||||
}
|
||||
}
|
||||
|
@@ -428,7 +428,7 @@ public class AntPathMatcher {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test whether or not a string matches against a pattern.
|
||||
* Test whether a string matches against a pattern.
|
||||
*
|
||||
* @param pattern the pattern to match against (never {@code null})
|
||||
* @param str the String which must be matched against the pattern (never {@code null})
|
||||
|
@@ -89,7 +89,7 @@ public class ArrayUtil extends PrimitiveArrayUtil {
|
||||
* 数组是否为非空<br>
|
||||
* 此方法会匹配单一对象,如果此对象为{@code null}则返回false<br>
|
||||
* 如果此对象为非数组,理解为此对象为数组的第一个元素,则返回true<br>
|
||||
* 如果此对象为数组对象,数组长度大于0情况下返回true,否则返回false
|
||||
* 如果此对象为数组对象,数组长度大于0的情况下返回true,否则返回false
|
||||
*
|
||||
* @param array 数组
|
||||
* @return 是否为非空
|
||||
|
@@ -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