mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
修复删除Path时如果为null时空指针bug
This commit is contained in:
parent
590e07a595
commit
b591f153b3
@ -165,7 +165,7 @@ public class PathUtil {
|
|||||||
* @since 4.4.2
|
* @since 4.4.2
|
||||||
*/
|
*/
|
||||||
public static boolean del(Path path) throws IORuntimeException {
|
public static boolean del(Path path) throws IORuntimeException {
|
||||||
if (Files.notExists(path)) {
|
if (null == path || Files.notExists(path)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ import static org.junit.jupiter.api.Assertions.*;
|
|||||||
import org.junit.jupiter.api.Disabled;
|
import org.junit.jupiter.api.Disabled;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.nio.file.StandardCopyOption;
|
import java.nio.file.StandardCopyOption;
|
||||||
|
|
||||||
@ -93,4 +94,11 @@ public class PathUtilTest {
|
|||||||
public void moveTest2(){
|
public void moveTest2(){
|
||||||
PathUtil.move(Paths.get("D:\\project\\test1.txt"), Paths.get("D:\\project\\test2.txt"), false);
|
PathUtil.move(Paths.get("D:\\project\\test1.txt"), Paths.get("D:\\project\\test2.txt"), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Disabled
|
||||||
|
public void delNullDirTest() {
|
||||||
|
Path path = null;
|
||||||
|
assertTrue(PathUtil.del(path));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user