mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
fix code
This commit is contained in:
parent
b696ad4b08
commit
3b1a375096
@ -1810,8 +1810,21 @@ public class CharSequenceUtil extends StrChecker {
|
|||||||
* @param length 要截取的长度
|
* @param length 要截取的长度
|
||||||
* @return 截取后的字符串
|
* @return 截取后的字符串
|
||||||
*/
|
*/
|
||||||
public static String subWithLength(final String input, final int fromIndex, final int length) {
|
public static String subByLength(final String input, final int fromIndex, final int length) {
|
||||||
return sub(input, fromIndex, fromIndex + length);
|
if (isEmpty(input)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (length <= 0) {
|
||||||
|
return EMPTY;
|
||||||
|
}
|
||||||
|
|
||||||
|
final int toIndex;
|
||||||
|
if(fromIndex < 0){
|
||||||
|
toIndex = fromIndex - length;
|
||||||
|
}else{
|
||||||
|
toIndex = fromIndex + length;
|
||||||
|
}
|
||||||
|
return sub(input, fromIndex, toIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
package cn.hutool.core.tree;
|
package cn.hutool.core.tree;
|
||||||
|
|
||||||
import cn.hutool.core.lang.builder.Builder;
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.lang.Assert;
|
import cn.hutool.core.lang.Assert;
|
||||||
import cn.hutool.core.tree.parser.NodeParser;
|
import cn.hutool.core.lang.builder.Builder;
|
||||||
import cn.hutool.core.map.MapUtil;
|
import cn.hutool.core.map.MapUtil;
|
||||||
|
import cn.hutool.core.tree.parser.NodeParser;
|
||||||
import cn.hutool.core.util.ObjUtil;
|
import cn.hutool.core.util.ObjUtil;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -56,7 +55,7 @@ public class TreeBuilder<E> implements Builder<MapTree<E>> {
|
|||||||
public TreeBuilder(final E rootId, final TreeNodeConfig config) {
|
public TreeBuilder(final E rootId, final TreeNodeConfig config) {
|
||||||
root = new MapTree<>(config);
|
root = new MapTree<>(config);
|
||||||
root.setId(rootId);
|
root.setId(rootId);
|
||||||
this.idTreeMap = new HashMap<>();
|
this.idTreeMap = new LinkedHashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -212,4 +212,10 @@ public class CharSequenceUtilTest {
|
|||||||
final String result = StrUtil.replaceFirst(str, "YES", "", true);
|
final String result = StrUtil.replaceFirst(str, "YES", "", true);
|
||||||
Assert.assertEquals(result, " and yes i do");
|
Assert.assertEquals(result, " and yes i do");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void issueI5YN49Test() {
|
||||||
|
final String str = "A5E6005700000000000000000000000000000000000000090D0100000000000001003830";
|
||||||
|
Assert.assertEquals("38", StrUtil.subByLength(str,-2,2));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -240,4 +240,11 @@ public class HttpRequestTest {
|
|||||||
final HttpRequest a = HttpRequest.post("https://hutool.cn/").form("a", 1);
|
final HttpRequest a = HttpRequest.post("https://hutool.cn/").form("a", 1);
|
||||||
Console.log(a.toString());
|
Console.log(a.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Ignore
|
||||||
|
public void issueI5Y68WTest() {
|
||||||
|
final HttpResponse httpResponse = HttpRequest.get("http://82.157.17.173:8100/app/getAddress").execute();
|
||||||
|
Console.log(httpResponse.body());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user