/** String 转数组 */ public static String[] StringToArray(String str){ String[] arr=new String[]{}; if(StringUtils.isNotEmpty(str)){ str= str.replaceAll("\\[","").replaceAll("]","") .replaceAll(" ","") .replaceAll("\"",""); arr=str.split(","); } return arr; } /** String 转Int数组 */ public static int[] StringToIntArray(String str){ int[] arr=new int[]{}; if(StringUtils.isNotEmpty(str)){ str= str.replaceAll("\\[","").replaceAll("]","") .replaceAll(" ","") .replaceAll("\"",""); String[] tagId=str.split(","); // 字符串数组转int数组 arr = Arrays.stream(tagId).mapToInt(Integer::parseInt).toArray(); } return arr; }
java 字符串转数组
最新推荐文章于 2023-02-16 16:48:46 发布