|
@@ -274,57 +274,66 @@ public class StringUtil extends org.apache.commons.lang3.StringUtils {
|
|
|
System.out.print(a);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 根据正则截取字符串
|
|
|
- * @return
|
|
|
- */
|
|
|
- public static int getArrayElementPosition(String[] actualWeldInfo,String actualWeld) {
|
|
|
- Arrays.sort(actualWeldInfo);
|
|
|
- int position = Arrays.binarySearch(actualWeldInfo, actualWeld);
|
|
|
- return position;
|
|
|
- }
|
|
|
+ /**
|
|
|
+ * 根据正则截取字符串
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static int getArrayElementPosition(String[] actualWeldInfo,String actualWeld) {
|
|
|
+ Arrays.sort(actualWeldInfo);
|
|
|
+ int position = Arrays.binarySearch(actualWeldInfo, actualWeld);
|
|
|
+ return position;
|
|
|
+ }
|
|
|
|
|
|
- /**
|
|
|
- * 格式化字符串中的小数点
|
|
|
- */
|
|
|
- public static String formatDecimal(String str) {
|
|
|
- str = str.replaceAll("[.](.*)","");
|
|
|
- return str;
|
|
|
- }
|
|
|
+ /**
|
|
|
+ * 格式化字符串中的小数点
|
|
|
+ */
|
|
|
+ public static String formatDecimal(String str) {
|
|
|
+ str = str.replaceAll("[.](.*)","");
|
|
|
+ return str;
|
|
|
+ }
|
|
|
|
|
|
- /**
|
|
|
- * 四舍五入小数
|
|
|
- */
|
|
|
- public static String formatDecimalFiveIn(String str) {
|
|
|
- str = String.valueOf(Math.round(Float.parseFloat(str)));
|
|
|
- return str;
|
|
|
- }
|
|
|
+ /**
|
|
|
+ * 四舍五入小数
|
|
|
+ */
|
|
|
+ public static String formatDecimalFiveIn(String str) {
|
|
|
+ str = String.valueOf(Math.round(Float.parseFloat(str)));
|
|
|
+ return str;
|
|
|
+ }
|
|
|
|
|
|
-// public static void main(String args[]){
|
|
|
-//// String[] intArray = new String[]{"a","b","c","d","e","f","g","h","i","j",};
|
|
|
-//// String actualWeld = "vt1684_pt793_50_500,vt1684_ut793_30_300,vt1684_rt793_60_600,vt1684_mt793_60_600";
|
|
|
-//// String[] actualWeldInfo = actualWeld.split(",");
|
|
|
-//// Arrays.sort(actualWeldInfo);
|
|
|
-//// int positon = Arrays.binarySearch(actualWeldInfo, "vt1684_pt793_50_500");
|
|
|
-//// System.out.println("position is:"+positon);
|
|
|
-// String actualWeld = formatDecimal(String.valueOf(1000.98));
|
|
|
-// System.out.print(actualWeld);
|
|
|
-// }
|
|
|
+ public static int querySpecificCharacter(String flawInspectCode) {
|
|
|
+ int count = 0;
|
|
|
+ int strLength = flawInspectCode.length();
|
|
|
+ String searchChar = "R";
|
|
|
+ flawInspectCode = flawInspectCode.replace(searchChar, "");
|
|
|
+ int newLength = flawInspectCode.length();
|
|
|
+ count = strLength - newLength;
|
|
|
+ return count;
|
|
|
+ }
|
|
|
|
|
|
- public static int querySpecificCharacter(String flawInspectCode) {
|
|
|
- int count = 0;
|
|
|
- int strLength = flawInspectCode.length();
|
|
|
- String searchChar = "R";
|
|
|
- flawInspectCode = flawInspectCode.replace(searchChar, "");
|
|
|
- int newLength = flawInspectCode.length();
|
|
|
- count = strLength - newLength;
|
|
|
- return count;
|
|
|
- }
|
|
|
+ public static String getUUID(){
|
|
|
+ String uuid = UUID.randomUUID().toString().replaceAll("-","");
|
|
|
+ return uuid;
|
|
|
+ }
|
|
|
|
|
|
- public static String getUUID(){
|
|
|
- String uuid = UUID.randomUUID().toString().replaceAll("-","");
|
|
|
- return uuid;
|
|
|
+ /**
|
|
|
+ * 在特定符号前插入字符串
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static String insertSpecificCharacter(String character,String charsToInsert){
|
|
|
+ String formatCharacter = "";
|
|
|
+ if (isNotBlank(character)&&isNotBlank(charsToInsert)){
|
|
|
+ // 在.号之前插入特殊字符
|
|
|
+ int indexOfSpace = character.indexOf(".");
|
|
|
+ if (indexOfSpace != -1) {
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
+ sb.append(character);
|
|
|
+ // 在索引为index处插入字符chars
|
|
|
+ sb.insert(indexOfSpace, charsToInsert);
|
|
|
+ formatCharacter = sb.toString();
|
|
|
+ }
|
|
|
}
|
|
|
+ return formatCharacter;
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 判断是否包含字母
|