package com.xjj.framework.utils;
/**
* @author xjj
*/
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Vector;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.log4j.Logger;
public class StringUtils {
/**
* Logger for this class
*/
private static final Logger logger = Logger.getLogger(StringUtils.class);
/**
* 将字符串转化为中文编码gb2312,默认输入的格式为iso-8859-1
*
* @param strInput
* 输入字符串
* @return
*/
public static String convertToChinese(String strInput) {
return convertToChinese(strInput, "iso-8859-1");
}
/**
* 将字符串转化为中文编码gb2312
*
* @param strInput
* 输入文本
* @param srcEncode
* 输入的格式
* @return
*/
public static String convertToChinese(String strInput, String srcEncode) {
String str = "";
try {
str = new String(strInput.getBytes(srcEncode), "gb2312");
} catch (Exception e) {
logger.error(e.getMessage());
return strInput;
}
return str;
}
/**
* 将列表中的文本前后加入指定字符
*
* @param list
* 字符串列表
* @param appStr
* 添加的指定字符
* @return
*/
public static List<String> appendAll(List<String> list, String appStr) {
List<String> tmpList = new ArrayList<String>();
;
for (String str : list) {
str = appStr + str + appStr;
tmpList.add(str);
}
return tmpList;
}
/**
* 将列表中的文本前面加入指定字符
*
* @param list
* 字符串列表
* @param appStr
* 添加的指定字符
* @return
*/
public static List<String> appendFore(List<String> list, String appStr) {
List<String> tmpList = new ArrayList<String>();
;
for (String str : list) {
str = appStr + str;
tmpList.add(str);
}
return tmpList;
}
/**
* 将列表中的文本后面加入指定字符
*
* @param list
* 字符串列表
* @param appStr
* 添加的指定字符
* @return
*/
public static List<String> appendBack(List<String> list, String appStr) {
List<String> tmpList = new ArrayList<String>();
;
for (String str : list) {
str = str + appStr;
tmpList.add(str);
}
return tmpList;
}
/**
* 将列表中的字符串合并
*
* @param list
* 列表
* @param delim
* 分隔符
* @return
*/
public static String join(List<String> list, String delim) {
if (list == null || list.size() < 1) {
return null;
}
if (delim == null) {
delim = "";
}
StringBuffer buf = new StringBuffer();
for (String str : list) {
buf.append(str);
buf.append(delim);
}
return buf.toString().substring(0, buf.toString().lastIndexOf(delim));
}
/**
* 将列表中的字符串合并
*
* @param list
* 列表
* @return
*/
public static String join(Object... list) {
if (list == null || list.length == 0) {
return "";
}
StringBuilder builder = new StringBuilder();
for (Object c : list) {
builder.append(c);
}
return builder.toString();
}
/**
* 将字符窜拆成数组
*
* @param str
* 带拆分的字符串
* @param delim
* 分隔符
* @return
*/
public static String[] splitToArray(String str, String delim) {
if (delim == null || delim.equals(""))
delim = ",";
String[] ret = new String[] {};
if (str == null || str.equals("")) {
return ret;
}
if (str.indexOf(delim) < 0) {
return new String[] { str.trim() };
}
Vector<String> splitList = new Vector<String>();
for (String s : str.split(delim)) {
String trimmed = s.trim();
if (trimmed.length() > 0)
splitList.add(trimmed);
}
return splitList.toArray(ret);
}
/**
* 将字符窜拆成List列表
*
* @param str
* 带拆分的字符串
* @param delim
* 分隔符
* @return
*/
public static List<String> splitToList(String str, String delim) {
if (delim == null || delim.equals(""))
delim = ",";
List<String> splitList = new ArrayList<String>();
for (String s : str.split(delim)) {
String trimmed = s.trim();
if (trimmed.length() > 0)
splitList.add(trimmed);
}
return splitList;
}
/**
* 将字符窜拆成Set
*
* @param str
* 带拆分的字符串
* @param delim
* 分隔符
* @return
*/
public static Set<String> splitToSet(String str, String delim) {
if (delim == null || delim.equals(""))
delim = ",";
Set<String> splitSet = new HashSet<String>();
;
for (String s : str.split(delim)) {
String trimmed = s.trim();
if (trimmed.length() > 0)
splitSet.add(trimmed);
}
return splitSet;
}
/**
* 截断过长的以空格分割的单词
*
* @param str
* 被截断的字符串
* @param maxLength
* 最大长度
* @return
*/
public static String createBreaks(String str, int maxLength) {
char chars[] = str.toCharArray();
int len = chars.length;
StringBuffer buf = new StringBuffer(len);
int count = 0;
int cur = 0;
for (int i = 0; i < len; i++) {
if (Character.isWhitespace(chars[i])) {
count = 0;
}
if (count >= maxLength) {
count = 0;
buf.append(chars, cur, i - cur).append(" ");
cur = i;
}
count++;
}
buf.append(chars, cur, len - cur);
return buf.toString();
}
/**
* 格式化SQL语句标志
*
* @param str
* @return
*/
public static String escapeSQLTags(String str) {
if (str == null || str.length() == 0) {
return str;
}
StringBuffer buf = new StringBuffer();
char ch = ' ';
for (int i = 0; i < str.length(); i++) {
ch = str.charAt(i);
if (ch == '\\') {
buf.append("\\\\");
} else if (ch == '\'') {
buf.append("\'\'");
} else {
buf.append(ch);
}
}
return buf.toString();
}
/**
* 格式化html文本,将html文本进行编码
*
* @param str
* @return
*/
public static String escapeHTMLTags(String str) {
if (str == null || str.length() == 0) {
return str;
}
StringBuffer buf = new StringBuffer();
char ch = ' ';
for (int i = 0; i < str.length(); i++) {
ch = str.charAt(i);
if (ch == '<') {
buf.append("<");
} else if (ch == '>') {
buf.append(">");
} else if (ch == '&') {
buf.append("&");
} else if (ch == '"') {
buf.append(""");
} else if (ch == ' ') {
buf.append(" ");
} else {
buf.append(ch);
}
}
return buf.toString();
}
/**
* 反格式化html文本,将html中的编码转化为对应格式
*
* @param str
* @return
*/
public static String toHTMLTags(String str) {
if (str == null || str.length() == 0) {
return str;
}
return str.replaceAll("<", "<").replaceAll(">", ">")
.replaceAll("&", "&").replaceAll(""", "\"")
.replaceAll(" ", " ");
}
/**
* 将换行转换为html标签
*
* @param str
* @return
*/
public static String convertNewlines(String str) {
str = replace(str, "\r\n", "<P>");
str = replace(str, "\n", "<BR>");
return str;
}
/**
* 替换字符串中的字符
*
* @param str
* 待替换的字符串
* @param oldString
* 旧字符
* @param newString
* 新字符
* @return
*/
public static String replace(String str, String oldString, String newString) {
if (str == null) {
return null;
}
int i = str.lastIndexOf(oldString);
if (i < 0) {
return str;
}
StringBuffer mainSb = new StringBuffer(str);
while (i >= 0) {
mainSb.replace(i, i + oldString.length(), newString);
i = str.lastIndexOf(oldString, i - 1);
}
return mainSb.toString();
}
/**
* 检�
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
Java EE(J2EE)快速开发框架jeexjj,基于主流技术(Springboot、Spring MVC、MyBatis、Bootstrap、ACE),是XJJ框架的springboot版本。系统的代码生动生成、极简权限框架、通用service和dao设计、后台页面设计….zip项目工程资源经过严格测试可直接运行成功且功能正常的情况才上传,可轻松copy复刻,拿到资料包后可轻松复现出一样的项目,本人系统开发经验充足(全栈开发),有任何使用问题欢迎随时与我联系,我会及时为您解惑,提供帮助 【资源内容】:项目具体内容可查看/点击本页面下方的*资源详情*,包含完整源码+工程文件+说明(若有)等 【本人专注计算机领域】:有任何使用问题欢迎随时与我联系,我会及时解答,第一时间为您提供帮助 【附带帮助】:若还需要相关开发工具、学习资料等,我会提供帮助,提供资料,鼓励学习进步 【适合场景】:相关项目设计中,皆可应用在项目开发、毕业设计、课程设计、期末/期中/大作业、工程实训、大创等学科竞赛比赛、初期项目立项、学习/练手等方面中 可借鉴此优质项目实现复刻,也可基于此项目来扩展开发出更多功能 #注
资源推荐
资源详情
资源评论
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![application/x-zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![md](https://img-home.csdnimg.cn/images/20210720083646.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
收起资源包目录
![package](https://csdnimg.cn/release/downloadcmsfe/public/img/package.f3fc750b.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
共 514 条
- 1
- 2
- 3
- 4
- 5
- 6
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/309be5d44dcf405b95f4d68867656dba_qrsds.jpg!1)
专家大圣
- 粉丝: 1446
- 资源: 6298
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
最新资源
- stm32C8T6 驱动mpu6050 网上代码扒下来的,自己又改了一部分希望有帮助 实测通过
- 基于多目标遗传算法的分布式电源选址定容研究 关键词:分布式电源 选址定容 多目标遗传算法 参考文档:《店主自写文档》基本复
- 基于CNN、RNN、SVM分别实现心电图分类识别python源码
- “丢失 api-ms-win-crt-runtime-l1-1-0.dll” “找不到MSVCR100.dll等等”等错误
- 基于单片STM32的mp3解码器wav播放器
- 160001-2-12-1222.nda
- openGauss 的Java驱动
- 如何在Java中实现多重继承
- VB获取CPU内存占用率及网卡流量监控
- java类和接口有什么区别
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)