mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
add method
This commit is contained in:
@@ -3,15 +3,17 @@
|
|||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
# 5.5.9 (2021-02-03)
|
# 5.5.9 (2021-02-18)
|
||||||
|
|
||||||
### 新特性
|
### 新特性
|
||||||
* 【crypto 】 PemUtil.readPemKey支持EC(pr#1366@Github)
|
* 【crypto 】 PemUtil.readPemKey支持EC(pr#1366@Github)
|
||||||
* 【extra 】 Ftp等cd方法增加同步(issue#1397@Github)
|
* 【extra 】 Ftp等cd方法增加同步(issue#1397@Github)
|
||||||
|
* 【core 】 StrUtil增加endWithAnyIgnoreCase(issue#I37I0B@Gitee)
|
||||||
|
|
||||||
### Bug修复
|
### Bug修复
|
||||||
* 【json 】 JSONUtil.isJson方法改变trim策略,解决特殊空白符导致判断失败问题
|
* 【json 】 JSONUtil.isJson方法改变trim策略,解决特殊空白符导致判断失败问题
|
||||||
* 【json 】 修复SQLEXception导致的栈溢出(issue#1399@Github)
|
* 【json 】 修复SQLEXception导致的栈溢出(issue#1399@Github)
|
||||||
|
* 【extra 】 修复Ftp中异常参数没有传入问题(issue#1397@Github)
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@@ -839,6 +839,28 @@ public class CharSequenceUtil {
|
|||||||
return false;
|
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
|
// ------------------------------------------------------------------------ contains
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -12,12 +12,13 @@ import java.util.regex.Pattern;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 字符串切分器
|
* 字符串切分器
|
||||||
* @author Looly
|
|
||||||
*
|
*
|
||||||
|
* @author Looly
|
||||||
*/
|
*/
|
||||||
public class StrSpliter {
|
public class StrSpliter {
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------- Split by char
|
//---------------------------------------------------------------------------------------------- Split by char
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 切分字符串路径,仅支持Unix分界符:/
|
* 切分字符串路径,仅支持Unix分界符:/
|
||||||
*
|
*
|
||||||
@@ -386,8 +387,10 @@ public class StrSpliter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------- Split by regex
|
//---------------------------------------------------------------------------------------------- Split by regex
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过正则切分字符串
|
* 通过正则切分字符串
|
||||||
|
*
|
||||||
* @param str 字符串
|
* @param str 字符串
|
||||||
* @param separatorRegex 分隔符正则
|
* @param separatorRegex 分隔符正则
|
||||||
* @param limit 限制分片数
|
* @param limit 限制分片数
|
||||||
@@ -403,6 +406,7 @@ public class StrSpliter {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过正则切分字符串
|
* 通过正则切分字符串
|
||||||
|
*
|
||||||
* @param str 字符串
|
* @param str 字符串
|
||||||
* @param separatorPattern 分隔符正则{@link Pattern}
|
* @param separatorPattern 分隔符正则{@link Pattern}
|
||||||
* @param limit 限制分片数
|
* @param limit 限制分片数
|
||||||
@@ -483,8 +487,10 @@ public class StrSpliter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------- Private method start
|
//---------------------------------------------------------------------------------------------------------- Private method start
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 将字符串加入List中
|
* 将字符串加入List中
|
||||||
|
*
|
||||||
* @param list 列表
|
* @param list 列表
|
||||||
* @param part 被加入的部分
|
* @param part 被加入的部分
|
||||||
* @param isTrim 是否去除两端空白符
|
* @param isTrim 是否去除两端空白符
|
||||||
@@ -503,6 +509,7 @@ public class StrSpliter {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* List转Array
|
* List转Array
|
||||||
|
*
|
||||||
* @param list List
|
* @param list List
|
||||||
* @return Array
|
* @return Array
|
||||||
*/
|
*/
|
||||||
|
@@ -82,7 +82,12 @@ public abstract class AbstractFtp implements Closeable {
|
|||||||
public boolean exist(String path) {
|
public boolean exist(String path) {
|
||||||
final String fileName = FileUtil.getName(path);
|
final String fileName = FileUtil.getName(path);
|
||||||
final String dir = StrUtil.removeSuffix(path, fileName);
|
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);
|
return containsIgnoreCase(names, fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -346,7 +346,7 @@ public class Ftp extends AbstractFtp {
|
|||||||
if (StrUtil.isNotBlank(path)) {
|
if (StrUtil.isNotBlank(path)) {
|
||||||
pwd = pwd();
|
pwd = pwd();
|
||||||
if(false == cd(path)){
|
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 fileName = FileUtil.getName(path);
|
||||||
final String dir = StrUtil.removeSuffix(path, fileName);
|
final String dir = StrUtil.removeSuffix(path, fileName);
|
||||||
if(false == cd(dir)){
|
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;
|
boolean isSuccess;
|
||||||
@@ -528,7 +528,7 @@ public class Ftp extends AbstractFtp {
|
|||||||
if (StrUtil.isNotBlank(path)) {
|
if (StrUtil.isNotBlank(path)) {
|
||||||
mkDirs(path);
|
mkDirs(path);
|
||||||
if (false == cd(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)){
|
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) {
|
if (null != fileNameCharset) {
|
||||||
|
Reference in New Issue
Block a user