List of usage examples for java.util StringTokenizer StringTokenizer
public StringTokenizer(String str, String delim)
From source file:Main.java
public static String GetFileName(String file) { StringTokenizer st = new StringTokenizer(file, "/"); while (st.hasMoreTokens()) { file = st.nextToken();//from w w w. j a va2 s. c o m } return file; }
From source file:Main.java
private static String[] parseCommandStr(String str) { StringTokenizer st = new StringTokenizer(str, "|"); String[] command_arr = new String[st.countTokens()]; int i = 0;/* ww w . ja v a2s.c o m*/ while (st.hasMoreElements()) { command_arr[i] = (String) st.nextElement(); i++; } return command_arr; }
From source file:Main.java
public static String[] parseExtensions(String extensions) { StringTokenizer st = new StringTokenizer(extensions, ","); String[] ext = new String[st.countTokens()]; int i = 0;/*from w w w . j a v a 2s. c o m*/ while (st.hasMoreTokens()) { ext[i++] = st.nextToken(); } return ext; }
From source file:Main.java
private static String getPathBeforeLastInPathElement(String path) { StringTokenizer st = new StringTokenizer(path, "."); StringBuffer sb = new StringBuffer(); int cpt = st.countTokens(); // if (cpt==1) // return root; int i = cpt - 1; for (int j = 0; j < i; j++) { String token = st.nextToken(); sb.append(token);//from www .ja v a 2 s . c o m if (j != i - 1) sb.append("."); } return sb.toString(); // String last = getLastInPathElement(path); // path = StringUtils.substringBefore(path, last); // return }
From source file:Main.java
public static ArrayList splitStringByCharC(String str, String c) { StringTokenizer en = new StringTokenizer(str, c); ArrayList vec = new ArrayList(); while (en.hasMoreElements()) vec.add(en.nextElement());/*www.j av a2s .com*/ return vec; }
From source file:Main.java
public static int stringIPtoInt(String ip) { StringTokenizer ipTokens = new StringTokenizer(ip, "."); int ipArray[] = new int[4]; ipArray[0] = Integer.parseInt(ipTokens.nextToken()); ipArray[1] = Integer.parseInt(ipTokens.nextToken()); ipArray[2] = Integer.parseInt(ipTokens.nextToken()); ipArray[3] = Integer.parseInt(ipTokens.nextToken()); return (ipArray[0] << 24) + (ipArray[1] << 16) + (ipArray[2] << 8) + ipArray[3]; }
From source file:Main.java
public static boolean valiChar(String string) { StringTokenizer s = new StringTokenizer(string, ","); // int num=0; if (s.hasMoreTokens()) { String str = s.nextToken(); byte[] cc = str.getBytes(); int a = (int) cc[0]; if (a < 32 || a > 127) { return false; }//from w w w. jav a 2s .c o m } return true; }
From source file:Main.java
public static Integer[] getMinSec(String str) { Integer[] data = new Integer[2]; StringTokenizer tokens = new StringTokenizer(str, ","); int counter = 0; while (tokens.hasMoreTokens()) { String next = tokens.nextToken(); data[counter++] = Integer.valueOf(next); }//from w w w . j a va 2s.c om return data; }
From source file:Main.java
public static ArrayList<String> splitInputStringIntoWords(String msg) { StringTokenizer token = new StringTokenizer(msg, " "); ArrayList<String> wordsList = new ArrayList<String>(); String nextWord;/* w ww . j a va 2s . c om*/ while (token.hasMoreTokens()) { nextWord = token.nextToken(); // Log.d(TAG, " inside getWords while loop.. nextToken - " + // nextWord); wordsList.add(nextWord); } return wordsList; }
From source file:Main.java
public static String tag(String inElement, String inString) { StringTokenizer wkTok = new StringTokenizer(inElement, " "); String wkElementOnly = inElement; wkElementOnly = wkTok.nextToken();/*from w w w .j av a 2 s . co m*/ return tag(inElement) + inString + etag(wkElementOnly); }