List of usage examples for java.lang String split
public String[] split(String regex)
From source file:Main.java
public static Integer getColorFromRgb(String rgb) { String[] rgbArray = rgb.split("\\s+"); int color = Color.rgb(Integer.valueOf(rgbArray[0]), Integer.valueOf(rgbArray[1]), Integer.valueOf(rgbArray[2])); return color; }
From source file:Main.java
/** * It splits the 'data' string until the 'buscar' string is reached * @param data main string to be splitted * @param buscar substring to search in 'data' * @return the substring found in 'data' */// w ww .ja v a 2 s .c om public static String splitFixed(String data, String buscar) { String[] parts = data.split(buscar); parts = parts[2].split("\""); return buscar + "" + parts[0]; }
From source file:Main.java
public static Long[] strToLongArray(String str, String separator) { String[] sArr = str.split(","); Long[] lArr = new Long[sArr.length]; for (int i = 0; i < sArr.length; i++) { lArr[i] = Long.valueOf(sArr[i]); }/*w ww .j a v a 2 s . c om*/ return lArr; }
From source file:Main.java
public static LocalDate dateStringToDate(String datetime) { String[] dateTimeTemp = datetime.split(" "); String[] parcels = dateTimeTemp[0].split("-"); if (parcels.length == 3) { return new LocalDate(Integer.parseInt(parcels[0]), Integer.parseInt(parcels[1]), Integer.parseInt(parcels[2])); }//w w w.j a v a 2s.co m return null; }
From source file:Main.java
public static int whichType(String str) { String[] sourceStrArray = str.split(",,"); String firstStr = sourceStrArray[0]; if (sourceStrArray.length < 4) return 1; else if (sourceStrArray.length > 3 && ",C01".equalsIgnoreCase(firstStr)) return 2; else if (sourceStrArray.length > 3 && !",C01".equalsIgnoreCase(firstStr)) return 0; else/*from ww w . j a v a 2s . c o m*/ return -1; }
From source file:Main.java
public static String getIp(String str) { String ip;/* ww w. j a v a 2 s. c o m*/ String s = str.substring(7); String[] arrayStr = s.split(":"); ip = arrayStr[0]; return ip; }
From source file:Main.java
public static String getFolderName(String path) { String filename[] = path.split("/"); if (filename != null) { return filename[filename.length - 2]; }/*from www .j a v a2 s . co m*/ return null; }
From source file:Main.java
/** * get the file name from its absolute path * /*from www. j av a 2 s .com*/ * @param path * @return */ public static String pathToName(String path) { String[] parts = path.split("/"); String fileName = parts[parts.length - 1]; String[] nameParts = fileName.split("[.]"); String getName = ""; for (int m = 0; m < nameParts.length - 1; m++) { getName = getName + nameParts[m]; } return getName; }
From source file:Main.java
public static List<String> parseValuesString(String values) { return Arrays.asList(values.split(";")); }
From source file:Main.java
/** * Transform the raw ASCIIs to String by its value. "," is the separator. * /*from ww w .j a v a 2s . c o m*/ * e.g. if ASCIIs = "97", the result is "a". if ASCIIs = "97,98", the result is "ab". * * @param ASCIIs the raw ASCIIs require transforming * @return the String by its value */ public static String asciis2String(String ASCIIs) { String[] ASCIIss = ASCIIs.split(","); StringBuffer sb = new StringBuffer(); for (int i = 0; i < ASCIIss.length; i++) { sb.append((char) __ascii2Char(Integer.parseInt(ASCIIss[i]))); } return sb.toString(); }