Code example for StringTokenizer

Methods: hasMoreElements, nextToken

0
         * for the java.util.Locale  class. 
         * @param locale the locale to use. 
         * @see java.util.Locale 
         */ 
        public void setLocale(String locale) {
            StringTokenizer st = new StringTokenizer(locale, " \t\n\r\f,");
            try { 
                language = st.nextToken();
                if (st.hasMoreElements()) {
                    country = st.nextToken();
                    if (st.hasMoreElements()) {
                        variant = st.nextToken();
                        if (st.hasMoreElements()) {
                            throw new BuildException("bad locale format", 
                                                      getLocation()); 
                        } 
                    } 
                } else { 
                    country = "";
                } 
            } catch (NoSuchElementException e) {