add method

This commit is contained in:
Looly
2021-02-18 16:04:07 +08:00
parent 4405d7b8f9
commit f104eb8ecc
5 changed files with 231 additions and 195 deletions

View File

@@ -3,15 +3,17 @@
-------------------------------------------------------------------------------------------------------------
# 5.5.9 (2021-02-03)
# 5.5.9 (2021-02-18)
### 新特性
* 【crypto 】 PemUtil.readPemKey支持ECpr#1366@Github
* 【extra 】 Ftp等cd方法增加同步issue#1397@Github
* 【core 】 StrUtil增加endWithAnyIgnoreCaseissue#I37I0B@Gitee
### Bug修复
* 【json 】 JSONUtil.isJson方法改变trim策略解决特殊空白符导致判断失败问题
* 【json 】 修复SQLEXception导致的栈溢出issue#1399@Github
* 【extra 】 修复Ftp中异常参数没有传入问题issue#1397@Github
-------------------------------------------------------------------------------------------------------------

View File

@@ -839,6 +839,28 @@ public class CharSequenceUtil {
return false;
}
/**
* 给定字符串是否以任何一个字符串结尾(忽略大小写)<br>
* 给定字符串和数组为空都返回false
*
* @param str 给定字符串
* @param suffixes 需要检测的结尾字符串
* @return 给定字符串是否以任何一个字符串结尾
* @since 5.5.9
*/
public static boolean endWithAnyIgnoreCase(CharSequence str, CharSequence... suffixes) {
if (isEmpty(str) || ArrayUtil.isEmpty(suffixes)) {
return false;
}
for (CharSequence suffix : suffixes) {
if (endWith(str, suffix, true)) {
return true;
}
}
return false;
}
// ------------------------------------------------------------------------ contains
/**

View File

@@ -12,12 +12,13 @@ import java.util.regex.Pattern;
/**
* 字符串切分器
* @author Looly
*
* @author Looly
*/
public class StrSpliter {
//---------------------------------------------------------------------------------------------- Split by char
/**
* 切分字符串路径仅支持Unix分界符/
*
@@ -386,8 +387,10 @@ public class StrSpliter {
}
//---------------------------------------------------------------------------------------------- Split by regex
/**
* 通过正则切分字符串
*
* @param str 字符串
* @param separatorRegex 分隔符正则
* @param limit 限制分片数
@@ -403,6 +406,7 @@ public class StrSpliter {
/**
* 通过正则切分字符串
*
* @param str 字符串
* @param separatorPattern 分隔符正则{@link Pattern}
* @param limit 限制分片数
@@ -483,8 +487,10 @@ public class StrSpliter {
}
//---------------------------------------------------------------------------------------------------------- Private method start
/**
* 将字符串加入List中
*
* @param list 列表
* @param part 被加入的部分
* @param isTrim 是否去除两端空白符
@@ -503,6 +509,7 @@ public class StrSpliter {
/**
* List转Array
*
* @param list List
* @return Array
*/

View File

@@ -82,7 +82,12 @@ public abstract class AbstractFtp implements Closeable {
public boolean exist(String path) {
final String fileName = FileUtil.getName(path);
final String dir = StrUtil.removeSuffix(path, fileName);
final List<String> names = ls(dir);
final List<String> names;
try{
names = ls(dir);
} catch (FtpException ignore){
return false;
}
return containsIgnoreCase(names, fileName);
}

View File

@@ -346,7 +346,7 @@ public class Ftp extends AbstractFtp {
if (StrUtil.isNotBlank(path)) {
pwd = pwd();
if(false == cd(path)){
throw new FtpException("Change dir to [{}] error, maybe path not exist!");
throw new FtpException("Change dir to [{}] error, maybe path not exist!", path);
}
}
@@ -410,7 +410,7 @@ public class Ftp extends AbstractFtp {
final String fileName = FileUtil.getName(path);
final String dir = StrUtil.removeSuffix(path, fileName);
if(false == cd(dir)){
throw new FtpException("Change dir to [{}] error, maybe dir not exist!");
throw new FtpException("Change dir to [{}] error, maybe dir not exist!", path);
}
boolean isSuccess;
@@ -528,7 +528,7 @@ public class Ftp extends AbstractFtp {
if (StrUtil.isNotBlank(path)) {
mkDirs(path);
if (false == cd(path)) {
throw new FtpException("Change dir to [{}] error, maybe dir not exist!");
throw new FtpException("Change dir to [{}] error, maybe dir not exist!", path);
}
}
@@ -636,7 +636,7 @@ public class Ftp extends AbstractFtp {
}
if(false == cd(path)){
throw new FtpException("Change dir to [{}] error, maybe dir not exist!");
throw new FtpException("Change dir to [{}] error, maybe dir not exist!", path);
}
if (null != fileNameCharset) {