List of usage examples for java.util StringTokenizer nextToken
public String nextToken()
From source file:Main.java
private static String[] setPlacesToWatch(String placeWatch) { String[] places = { "" }; if (placeWatch != null && !placeWatch.equals("")) { StringTokenizer tok = new StringTokenizer(placeWatch, ","); List<String> l = new ArrayList<String>(); while (tok.hasMoreElements()) { l.add(tok.nextToken().toString()); }/*from w w w . j a v a 2 s .c om*/ if (!l.isEmpty()) { //Object[] o = l.toArray(); places = new String[l.size()];// (String[])o; int idx = 0; for (String s : l) { places[idx++] = s; } } } return places; }
From source file:Main.java
public static String[] getStorageDirectories() { String[] dirs = null;//from w ww .j a v a2s . c om BufferedReader bufReader = null; ArrayList<String> list = new ArrayList<String>(); list.add(Environment.getExternalStorageDirectory().getPath()); List<String> typeWL = Arrays.asList("vfat", "exfat", "sdcardfs", "fuse"); List<String> typeBL = Arrays.asList("tmpfs"); String[] mountWL = { "/mnt", "/Removable" }; String[] mountBL = { "/mnt/secure", "/mnt/shell", "/mnt/asec", "/mnt/obb", "/mnt/media_rw/extSdCard", "/mnt/media_rw/sdcard", "/storage/emulated" }; String[] deviceWL = { "/dev/block/vold", "/dev/fuse", "/mnt/media_rw/extSdCard" }; try { bufReader = new BufferedReader(new FileReader("/proc/mounts")); String line; while ((line = bufReader.readLine()) != null) { StringTokenizer tokens = new StringTokenizer(line, " "); String device = tokens.nextToken(); String mountpoint = tokens.nextToken(); String type = tokens.nextToken(); // skip if already in list or if type/mountpoint is blacklisted if (list.contains(mountpoint) || typeBL.contains(type) || StartsWith(mountBL, mountpoint)) continue; // check that device is in whitelist, and either type or mountpoint is in a whitelist if (StartsWith(deviceWL, device) && (typeWL.contains(type) || StartsWith(mountWL, mountpoint))) list.add(mountpoint); } dirs = new String[list.size()]; for (int i = 0; i < list.size(); i++) { dirs[i] = list.get(i); } } catch (FileNotFoundException e) { } catch (IOException e) { } finally { if (bufReader != null) { try { bufReader.close(); } catch (IOException e) { } } } return dirs; }
From source file:com.gistlabs.mechanize.impl.MechanizeInitializer.java
static List<String> getClassNames(final String forSystemProperty, final String orDefaultValue) { List<String> result = new ArrayList<String>(); String propertyValue = System.getProperty(forSystemProperty); if (propertyValue == null || "".equals(propertyValue)) propertyValue = orDefaultValue;/*w w w .j a v a 2s . c om*/ StringTokenizer tokenizer = new StringTokenizer(propertyValue, ","); while (tokenizer.hasMoreTokens()) result.add(tokenizer.nextToken().trim()); return result; }
From source file:com.salesmanager.core.util.LanguageUtil.java
public static List parseLanguages(String langs) { List lst = new ArrayList(); if (langs != null) { StringTokenizer st = new StringTokenizer(langs, ";"); while (st != null && st.hasMoreTokens()) { String lang = st.nextToken(); lst.add(lang);/* w ww . j ava 2 s . c o m*/ } } return lst; }
From source file:com.kixeye.chassis.bootstrap.aws.UserData.java
public static UserData parse(String userData) { if (!StringUtils.isBlank(userData)) { StringTokenizer stringTokenizer = new StringTokenizer(userData, "\n"); while (stringTokenizer.hasMoreTokens()) { String line = stringTokenizer.nextToken(); int envStartIdx = line.indexOf(ENVIRONMENT_TEXT); if (envStartIdx >= 0) { String env = line.substring(envStartIdx + ENVIRONMENT_TEXT.length()); return new UserData(StringUtils.trimToNull(env)); }/*from w w w .j a v a 2 s .c om*/ } } throw new BootstrapException("Found no environment data in user-data " + userData); }
From source file:com.sec.ose.osi.UIMain.java
private static double getJavaVersion() { Properties prop = System.getProperties(); String java_specification_version = prop.getProperty("java.specification.version"); StringTokenizer st = new StringTokenizer(java_specification_version, "."); String major = st.nextToken(); String minor = st.nextToken(); try {/* ww w .j a va2 s .co m*/ double version = Double.parseDouble(major + "." + minor); return version; } catch (NumberFormatException e) { log.warn(e); return 0; } }
From source file:Main.java
public static void appendParamValues(StringBuffer params, String tagValues, String tagName, String delim) { if (tagValues != null) { if (delim == null || delim.trim().length() == 0) { delim = ","; }// w w w.j a va 2 s .c om StringTokenizer st = new StringTokenizer(tagValues.trim(), delim); while (st.hasMoreTokens()) { params.append("<" + tagName + " id=\"" + encodeStringForXml(st.nextToken().trim()) + "\"></" + tagName + ">"); } } }
From source file:Main.java
protected static List<String> splitTrimmed(String text, String separator) { List<String> parts = new ArrayList<String>(); StringTokenizer st = new StringTokenizer(text, separator); while (st.hasMoreTokens()) { String token = st.nextToken().trim(); if (token.length() > 0) { parts.add(token);//from ww w . ja v a 2 s . co m } } return parts; }
From source file:Main.java
public static void initializeIrregularVerbMap() { try {/* w w w. ja v a2 s . c o m*/ BufferedReader reader = new BufferedReader(new FileReader(new File(FILE_NAME_IRREGULAR_VERB))); String line = null; while ((line = reader.readLine()) != null) { StringTokenizer tokenizer = new StringTokenizer(line, "\t\n", false); String root = null; if (tokenizer.hasMoreTokens()) root = tokenizer.nextToken().trim(); while (tokenizer.hasMoreTokens()) { irregularVerbMap.put(tokenizer.nextToken().trim(), root); } } } catch (FileNotFoundException e) { System.out.println("File not found in the system."); } catch (IOException e1) { System.out.println("IOException"); } }
From source file:Main.java
private static String[] split(String s, String delim, boolean includeDelim) { StringTokenizer tok = new StringTokenizer(s, delim, includeDelim); String[] parts = new String[tok.countTokens()]; for (int i = 0; tok.hasMoreTokens(); i++) { parts[i] = tok.nextToken(); }//w w w . java 2 s . c om return parts; }