List of usage examples for java.util StringTokenizer nextToken
public String nextToken()
From source file:Main.java
public static List<String> parseTokenList(String tokenList) { List<String> result = new ArrayList<>(); StringTokenizer tokenizer = new StringTokenizer(tokenList, " "); while (tokenizer.hasMoreTokens()) { result.add(tokenizer.nextToken()); }/* www . ja v a 2 s . c o m*/ return result; }
From source file:Main.java
/** * Remove leading a trailing whitespace characters from each line of input * @param input//from w ww . ja v a2 s . c o m * @return */ public static String trim(String input) { final String newlineDelimiters = "\n\r\f"; //$NON-NLS-1$ StringBuilder ret = new StringBuilder(); StringTokenizer st = new StringTokenizer(input, newlineDelimiters); while (st.hasMoreTokens()) { ret.append(st.nextToken().replaceAll("^\\s+", "").replaceAll("\\s+$", "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ ret.append("\n"); //$NON-NLS-1$ } return ret.toString(); }
From source file:TokenizerUtil.java
public static String[] convertCSVStringToArray(String s) { ArrayList<String> list = new ArrayList<String>(); StringTokenizer st = new StringTokenizer(s, "|"); while (st.hasMoreTokens()) { String token = st.nextToken(); list.add(token);/*from w w w . j av a 2s .co m*/ } return (String[]) list.toArray(new String[list.size()]); }
From source file:Main.java
private static boolean initOpenCVLibs(String Libs) { Log.d(TAG, "Trying to init OpenCV libs"); boolean result = true; if ((null != Libs) && (Libs.length() != 0)) { Log.d(TAG, "Trying to load libs by dependency list"); StringTokenizer splitter = new StringTokenizer(Libs, ";"); while (splitter.hasMoreTokens()) { result &= loadLibrary(splitter.nextToken()); }// w ww .j ava 2 s. co m } else { // If dependencies list is not defined or empty. result &= loadLibrary("opencv_java3"); } return result; }
From source file:Main.java
private static boolean initOpenCVLibs(String Libs) { Log.d(TAG, "Trying to init OpenCV libs"); boolean result = true; if ((null != Libs) && (Libs.length() != 0)) { Log.d(TAG, "Trying to load libs by dependency list"); StringTokenizer splitter = new StringTokenizer(Libs, ";"); while (splitter.hasMoreTokens()) { result &= loadLibrary(splitter.nextToken()); }//from w ww . jav a 2 s. co m } else { // If dependencies list is not defined or empty. result &= loadLibrary("opencv_java"); } return result; }
From source file:TokenizerUtil.java
public static Map<String, String> convertCSVStringToMap(String s) { TreeMap<String, String> map = new TreeMap<String, String>(); StringTokenizer st = new StringTokenizer(s, "|"); while (st.hasMoreTokens()) { String keyToken = st.nextToken(); String valueToken = st.nextToken(); map.put(keyToken, valueToken);/*from w w w . ja va2 s.c o m*/ } return map; }
From source file:Main.java
public static Node createNodeFromPath(Element modelElement, String path) { Document document = modelElement.getOwnerDocument(); StringTokenizer st = new StringTokenizer(path, "/"); while (st.hasMoreTokens()) { String t = st.nextToken(); if (st.hasMoreTokens()) { if (t.equals("..")) { modelElement = (Element) modelElement.getParentNode(); } else { Element elm = getFirstChildElement(modelElement, t); if (elm == null) modelElement = (Element) modelElement.insertBefore(document.createElement(t), getFirstChildElement(modelElement, t)); else modelElement = elm;/* w ww . j ava 2 s . c o m*/ } } else { modelElement = (Element) modelElement.insertBefore(document.createElement(t), getFirstChildElement(modelElement, t)); } } return modelElement; }
From source file:com.dc.gameserver.extComponents.Kit.ip.Util.java
/** * ip??/*from ww w .ja v a2s. co m*/ * * @param ip * ?ip * @return ?ip */ public static byte[] getIpByteArrayFromString(String ip) { byte[] ret = new byte[4]; StringTokenizer st = new StringTokenizer(ip, "."); try { ret[0] = (byte) (Integer.parseInt(st.nextToken()) & 0xFF); ret[1] = (byte) (Integer.parseInt(st.nextToken()) & 0xFF); ret[2] = (byte) (Integer.parseInt(st.nextToken()) & 0xFF); ret[3] = (byte) (Integer.parseInt(st.nextToken()) & 0xFF); } catch (Exception e) { log.info("ip??"); } return ret; }
From source file:Main.java
public static String[] toStringArray(String s) { StringTokenizer st = new StringTokenizer(s); String[] array = new String[st.countTokens()]; for (int i = 0; st.hasMoreTokens(); i++) array[i] = st.nextToken(); return array; }
From source file:Main.java
public static String getBuildVersionRelease() { String version = ""; try {//from w w w .j a v a 2 s . co m String release = Build.VERSION.RELEASE; StringTokenizer st = new StringTokenizer(release, "."); boolean first = true; while (st.hasMoreElements()) { String number = st.nextToken(); if (number != null) number = number.substring(0, 1); version = (first) ? number : version + "." + number; first = false; } } catch (Exception e) { } return version; }