List of usage examples for java.util StringTokenizer hasMoreTokens
public boolean hasMoreTokens()
From source file:gov.nih.nci.lv.util.LVUtils.java
/** * converts a ids seperated by a comma to a set. * @param ids ids//from w w w. j a v a 2 s.c o m * @param delimiter delimiter * @return Set */ public static Set<Long> convertStringToSet(String ids, String delimiter) { Set<Long> labs = new HashSet<Long>(); if (StringUtils.isEmpty(ids)) { return labs; } StringTokenizer st = new StringTokenizer(ids, delimiter); while (st.hasMoreTokens()) { labs.add(new Long(st.nextElement().toString())); } return labs; }
From source file:gov.nih.nci.lv.util.LVUtils.java
/** * converts a ids seperated by a comma to a set. * @param ids ids// w w w . j a va 2s. com * @param delimiter delimiter * @return Set */ public static List<Long> convertStringToList(String ids, String delimiter) { List<Long> labs = new ArrayList<Long>(); if (StringUtils.isEmpty(ids)) { return labs; } StringTokenizer st = new StringTokenizer(ids, delimiter); while (st.hasMoreTokens()) { labs.add(new Long(st.nextElement().toString())); } return labs; }
From source file:com.github.walterfan.util.http.URLHelper.java
/** * Parsers the query string of the URI into a map of key-value pairs */// ww w . ja v a 2s .c om public static Map<String, String> parseQuery(String query) { Map<String, String> answer = new HashMap<String, String>(); if (query != null) { StringTokenizer iter = new StringTokenizer(query, "&"); while (iter.hasMoreTokens()) { String pair = iter.nextToken(); addKeyValuePair(answer, pair); } } return answer; }
From source file:net.sf.j2ep.model.AllowedMethodHandler.java
/** * Will set the allowed methods, both by setting the string * and also by adding all the methods to the set of allowed. * @param allowed The list of allowed methods, should be comma separated *///from w w w . j a va 2s . c om @SuppressWarnings("unchecked") public synchronized static void setAllowedMethods(String allowed) { allowedMethods = new HashSet(); allowString = allowed; StringTokenizer tokenizer = new StringTokenizer(allowed, ","); while (tokenizer.hasMoreTokens()) { String token = tokenizer.nextToken().trim().toUpperCase(); allowedMethods.add(token); } }
From source file:net.sf.jabref.exporter.layout.WSITools.java
/** * @param vcr {@link java.util.Vector} of <tt>String</tt> * @param buf Description of the Parameter * @param delimstr Description of the Parameter * @return Description of the Return Value *//*w w w . j av a 2 s .c o m*/ public static boolean tokenize(Vector<String> vcr, String buf, String delimstr) { vcr.clear(); buf = buf + '\n'; StringTokenizer st = new StringTokenizer(buf, delimstr); while (st.hasMoreTokens()) { vcr.add(st.nextToken()); } return true; }
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;//from ww w . j a v a 2 s. co m while (token.hasMoreTokens()) { nextWord = token.nextToken(); // Log.d(TAG, " inside getWords while loop.. nextToken - " + // nextWord); wordsList.add(nextWord); } return wordsList; }
From source file:net.sf.j2ep.model.AllowedMethodHandler.java
/** * Will go through all the methods sent in * checking to see that the method is allowed. * If it's allowed it will be included//from w w w .jav a 2 s. co m * in the returned value. * * @param allowSent The header returned by the server * @return The allowed headers for this request */ public static String processAllowHeader(String allowSent) { StringBuffer allowToSend = new StringBuffer(""); StringTokenizer tokenizer = new StringTokenizer(allowSent, ","); while (tokenizer.hasMoreTokens()) { String token = tokenizer.nextToken().trim().toUpperCase(); if (allowedMethods.contains(token)) { allowToSend.append(token).append(","); } } return allowToSend.toString(); }
From source file:com.flipkart.phantom.task.utils.StringUtils.java
public static Map<String, String> getQueryParams(String httpUrl) { Map<String, String> params = new HashMap<String, String>(); if (httpUrl == null) { return params; }/*from w w w .ja v a 2s .co m*/ URL url = null; try { url = new URL(httpUrl); } catch (MalformedURLException e) { throw new RuntimeException(e); } String query = url.getQuery(); if (query == null) { return params; } StringTokenizer tokenizer = new StringTokenizer(query, "&"); while (tokenizer.hasMoreTokens()) { String token = tokenizer.nextToken(); int index = token.indexOf("="); params.put(token.substring(0, index).trim(), token.substring(index + 1).trim()); } return params; }
From source file:Main.java
public static int[] decodeMultiIntegerField(String field) throws NumberFormatException { StringTokenizer fieldTokens = new StringTokenizer(field, ";"); int[] result = new int[fieldTokens.countTokens()]; int counter = 0; while (fieldTokens.hasMoreTokens()) { String fieldToken = fieldTokens.nextToken(); result[counter++] = Integer.valueOf(fieldToken); }// ww w . j a va 2 s . c om return result; }
From source file:Main.java
public static void killProcess(String packageName) { String processId = ""; try {//from w ww .j av a2 s .c o m Runtime r = Runtime.getRuntime(); Process p = r.exec("ps"); BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream())); String inline; while ((inline = br.readLine()) != null) { if (packageName != null) { if (inline.contains(packageName)) { break; } } else { Log.e("PvTorrent_proc", "packageName is null"); } } br.close(); Log.i("PvTorrent_proc", "inline" + inline); if (inline != null) { StringTokenizer processInfoTokenizer = new StringTokenizer(inline); int count = 0; while (processInfoTokenizer.hasMoreTokens()) { count++; processId = processInfoTokenizer.nextToken(); if (count == 2) { break; } } Log.i("PvTorrent_proc", "kill process : " + processId); r.exec("kill -9 " + processId); } } catch (IOException ex) { Log.e("PvTorrent_proc", "kill" + ex.getStackTrace()); } }