/**
* 获取文件名和文件类型
* @param file
* @return
*/
public static ImmutablePair getFileNameAndExtension(String file) {
ImmutablePair<String, String> pair = ImmutablePair.of("", "");
if (file != null) {
if (file.contains("/")){
file = file.substring(file.lastIndexOf("/")+1);
}
String fileName = file.substring(0, file.lastIndexOf("."));
String fileSuffix = file.substring(file.lastIndexOf("."));
pair = ImmutablePair.of(fileName, fileSuffix);
}
return pair;
}
提取文本变量? 如 你好{name}? 提取name
正则提取文本
/**
* String pattern = "\\{[a-zA-Z0-9]*}";
* @param regex
* @param source
* @return
*/
public static List<String> getMatcher(String regex, String source) {
String result = "";
//String pattern = "{[a-zA-Z0-9]*}";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(source);
List<String> list = new ArrayList<>();
while (matcher.find()) {
result = matcher.group(0);
list.add(trimStr(result));
}
return list;
}
mysql插入时间少8小时问题 指定时区
jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
idea代码模板??
?
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
#parse("File Header.java")
/**
* @author Maobo
* @date ${YEAR}年${MONTH}月${DAY}日 ${TIME}
*/
public @interface ${NAME} {
}
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
#parse("File Header.java")
/**
* @author Maobo
* @date ${YEAR}年${MONTH}月${DAY}日 ${TIME}
*/
public enum ${NAME} {
}
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
#parse("File Header.java")
/**
* @author Maobo
* @date ${YEAR}年${MONTH}月${DAY}日 ${TIME}
*/
public interface ${NAME} {
}
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
#parse("File Header.java")
/**
* @author Maobo
* @date ${YEAR}年${MONTH}月${DAY}日 ${TIME}
*/
public class ${NAME} {
}
没什么好写的,为了保持一个月有一篇的好习惯,随便写点,有点水了
|