Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
Y
yzg-util
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
YZG
yzg-util
Commits
df002405
Commit
df002405
authored
Sep 18, 2020
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改MQ请求尸体,防止出错
parent
0f6d5671
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
0 deletions
+43
-0
StringHelper.java
...c/main/java/com/yanzuoguang/util/helper/StringHelper.java
+28
-0
TestStringHelper.java
yzg-util-base/src/test/java/helper/TestStringHelper.java
+15
-0
No files found.
yzg-util-base/src/main/java/com/yanzuoguang/util/helper/StringHelper.java
View file @
df002405
...
@@ -108,6 +108,34 @@ public class StringHelper {
...
@@ -108,6 +108,34 @@ public class StringHelper {
return
str
.
toString
();
return
str
.
toString
();
}
}
/**
* 取左边
*
* @param from
* @param size
* @return
*/
public
static
String
left
(
String
from
,
int
size
)
{
if
(
from
!=
null
)
{
return
from
.
substring
(
0
,
Math
.
min
(
from
.
length
(),
size
));
}
return
StringHelper
.
EMPTY
;
}
/**
* 取右边
*
* @param from
* @param size
* @return
*/
public
static
String
right
(
String
from
,
int
size
)
{
if
(
from
!=
null
)
{
return
from
.
substring
(
Math
.
max
(
from
.
length
()
-
size
,
0
));
}
return
StringHelper
.
EMPTY
;
}
/**
/**
* 传入很多值,返回第一个不等于排除值、空值的值,当全部为排除值时,返回默认值
* 传入很多值,返回第一个不等于排除值、空值的值,当全部为排除值时,返回默认值
...
...
yzg-util-base/src/test/java/helper/TestStringHelper.java
0 → 100755
View file @
df002405
package
helper
;
import
com.yanzuoguang.util.helper.StringHelper
;
import
org.junit.Test
;
public
class
TestStringHelper
{
@Test
public
void
test
()
{
System
.
out
.
println
(
StringHelper
.
left
(
"100500103"
,
3
));
System
.
out
.
println
(
StringHelper
.
left
(
"10"
,
3
));
System
.
out
.
println
(
StringHelper
.
right
(
"100500103"
,
3
));
System
.
out
.
println
(
StringHelper
.
right
(
"03"
,
3
));
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment