Java 8 StringTokenizer - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 StringTokenizer class.

This code example shows how to use the following methods: countTokens, nextToken
     * @param value The value to be parsed 
     * @throws IllegalArgumentException If the passed <code>value</code> cannot be 
     *                                  represented as an {@link IncrementValue} 
     */ 
    public IncrementValue(String value) {
        StringTokenizer tokenizer = new StringTokenizer(value, INCREMENT_SEPARATOR);
        int numberOfTokens = tokenizer.countTokens();
        if (numberOfTokens != 2) {
            throw MESSAGES.invalidIncrementValue(value);
        } 
 
        this.start = tokenizer.nextToken().trim();
        this.interval = tokenizer.nextToken().trim();
    } 
 
    /** 
     * Returns the start of this {@link IncrementValue} 
     * 
     * @return 
     */ 
Full Snippet Info
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: hasMoreElements, nextToken
This code example shows how to use the following methods: hasMoreTokens, nextToken
        checkValue("a", st1.nextToken("b"));
        st1.hasMoreTokens();
        checkValue("b", st1.nextToken(""));
 
        // Test with retDelims set to true 
        StringTokenizer st2 = new StringTokenizer("abcd efg", "abc", true);
        st2.hasMoreTokens();
        checkValue("a", st2.nextToken("bc"));
        st2.hasMoreTokens();
        checkValue("b", st2.nextToken());
        st2.hasMoreTokens();
        checkValue("cd", st2.nextToken(" ef"));
        st2.hasMoreTokens();
        checkValue(" ", st2.nextToken(" "));
        st2.hasMoreTokens();
        checkValue("ef", st2.nextToken("g"));
        st2.hasMoreTokens();
        checkValue("g", st2.nextToken("g"));
 
        // Test with changing delimiters 

7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: countTokens, nextToken
			   //no rows empty cursor 
			   return; 
			} 
 
			final String street = cur.getString(cur.getColumnIndexOrThrow(ContactsContract.CommonDataKinds.StructuredPostal.FORMATTED_ADDRESS));
			StringTokenizer token=new StringTokenizer(street, ",");
			boolean latlong=false;
			String latitude=null;
			String longitude=null;
			if(token.countTokens()==2){
				String temp=token.nextToken();
				if(temp.startsWith("loc:")){
					temp=temp.substring(4);
				} 
				 if (temp.trim().matches("((-|\\+)?[0-9]+(\\.[0-9]+)?)+")) {  
			            latitude=temp.trim();
			        }  
				 temp=token.nextToken();
				 if(temp.trim().matches("((-|\\+)?[0-9]+(\\.[0-9]+)?)+")){
					 longitude= temp.trim();

7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: countTokens, nextToken
	private WOHTMLWebObjectTag _parent;
	private NSMutableArray _children;
 
	private void extractName(String s) throws WOHelperFunctionHTMLFormatException {
 
		StringTokenizer stringtokenizer = new StringTokenizer(s, "=");
		if (stringtokenizer.countTokens() != 2) {
			throw new WOHelperFunctionHTMLFormatException("<WOHTMLWebObjectTag cannot initialize WebObject tag " + s + "> . It has no NAME=... parameter");
		} 
 
		stringtokenizer.nextToken();
		String s1 = stringtokenizer.nextToken();
 
		int i = s1.indexOf('"');
		if (i != -1) {
			int j = s1.lastIndexOf('"');
			if (j > i) {
				_name = s1.substring(i + 1, j);
			} 
		} 
Full Snippet Info
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: hasMoreTokens, nextToken
 
    public static class JsonMapper extends Mapper { 
 
        @Override 
        protected void map(Object key, Object value, Context context) throws IOException, InterruptedException {
            StringTokenizer st = new StringTokenizer(value.toString(), "\t");
            Map<String, String> entry = new LinkedHashMap<String, String>();
 
            entry.put("number", st.nextToken());
            entry.put("name", st.nextToken());
            entry.put("url", st.nextToken());
            if (st.hasMoreTokens()) {
                entry.put("picture", st.nextToken());
            } 
            context.write(key, WritableUtils.toWritable(entry));
        } 
    } 
 
    @Test 
    public void testBasicSave() throws Exception { 
Full Snippet Info
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: nextToken
    private float getFloat(Element elem) {
        return Float.parseFloat(getString(elem));
    } 
 
    private Float3 parseFloat3(String valueString) {
        StringTokenizer st = new StringTokenizer(valueString);
        float x = Float.parseFloat(st.nextToken());
        float y = Float.parseFloat(st.nextToken());
        float z = Float.parseFloat(st.nextToken());
        return new Float3(x, y, z);
    } 
 
    private Float4 parseFloat4(String valueString) {
        StringTokenizer st = new StringTokenizer(valueString);
        float x = Float.parseFloat(st.nextToken());
        float y = Float.parseFloat(st.nextToken());
        float z = Float.parseFloat(st.nextToken());
        float w = Float.parseFloat(st.nextToken());
        return new Float4(x, y, z, w);
    } 
Full Snippet Info
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: hasMoreElements, hasMoreTokens, nextToken
  { 
    if (s == null)
    { 
      throw new NullPointerException();
    } 
    final StringTokenizer strtok = new StringTokenizer(s.trim(), "_");
    if (strtok.hasMoreElements() == false)
    { 
      throw new BeanException("This is no valid locale specification."); 
    } 
    final String language = strtok.nextToken();
    String country = "";
    if (strtok.hasMoreTokens())
    { 
      country = strtok.nextToken();
    } 
    String variant = "";
    if (strtok.hasMoreTokens())
    { 
      variant = strtok.nextToken();

7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: hasMoreTokens, nextToken
    if (!tokens.hasMoreTokens()) {            // for long filesystem name
      line = lines.readLine();
      if (line == null) {
        throw new IOException( "Expecting a line not the end of stream" );
      } 
      tokens = new StringTokenizer(line, " \t\n\r\f%");
    } 
    Long.parseLong(tokens.nextToken()); // skip capacity
    Long.parseLong(tokens.nextToken()); // skip used
    Long.parseLong(tokens.nextToken()); // skip available
    Integer.parseInt(tokens.nextToken()); // skip percentUsed
    this.mount = tokens.nextToken();
  } 
 
  public static void main(String[] args) throws Exception {
    String path = ".";
    if (args.length > 0)
      path = args[0];
 
    System.out.println(new DF(new File(path), DF_INTERVAL_DEFAULT).toString());
Full Snippet Info
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: hasMoreTokens, nextToken
    } 
     
    static Locale localeFromString(String ls) {
        if (ls == null) ls = "";
        String lang="", country="", variant="";
        StringTokenizer st = new StringTokenizer(ls, "_-,");
        if (st.hasMoreTokens()) {
            lang = st.nextToken();
            if (st.hasMoreTokens()) {
                country = st.nextToken();
                if (st.hasMoreTokens()) {
                    variant = st.nextToken();
                } 
            } 
            return new Locale(lang, country, variant);
        } else { 
            return Locale.getDefault();
        } 
    } 
     
Full Snippet Info
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related Java 8 StringTokenizer Questions & Answers:

See Code Examples for Java 8 StringTokenizer Methods: