SupportClass.Tokenizer.NextToken C# (CSharp) Method

NextToken() public method

Returns the next token from the token list
public NextToken ( ) : string
return string
        public string NextToken()
        {
            string result;
                if (source == "") throw new System.Exception();
                else
                {
                    if(returnDelims){
            //						Tokenize();
                        RemoveEmptyStrings();
                        result = (string) this.elements[0];
                        this.elements.RemoveAt(0);
                        return result;
                    }
                    else
                    {
                        this.elements = new System.Collections.ArrayList();
                        this.elements.AddRange(this.source.Split(delimiters.ToCharArray()));
                        RemoveEmptyStrings();
                        result = (string) this.elements[0];
                        this.elements.RemoveAt(0);
                        this.source = this.source.Remove(this.source.IndexOf(result),result.Length);
                        this.source = this.source.TrimStart(this.delimiters.ToCharArray());
                        return result;
                    }
                }
        }

Same methods

SupportClass.Tokenizer::NextToken ( string delimiters ) : string

Usage Example

        /// <summary> Reads given "property file" and sets system properties accordingly.  In the property file,
        /// there should be one property per line.  A line should consist of 1) the fully qualified property name,
        /// 2) one or more tabs, and 3) the value (everything after the first group of tabs and before any subsequent
        /// groups will be considered "the value").
        /// Lines in the file are consdidered comments if they begin with "%".
        /// </summary>
        public static void  loadProperties(System.String propertyFileName)
        {
            //open stream from given property file
            System.IO.StreamReader in_Renamed = null;
            in_Renamed = new System.IO.StreamReader(new System.IO.StreamReader(propertyFileName, System.Text.Encoding.Default).BaseStream, new System.IO.StreamReader(propertyFileName, System.Text.Encoding.Default).CurrentEncoding);

            System.String          line, key, value_Renamed, delim = "\t";
            SupportClass.Tokenizer tok;
            while ((line = in_Renamed.ReadLine()) != null)
            {
                //ignore comments
                if (!line.StartsWith("%"))
                {
                    key = null; value_Renamed = null;

                    //get property key and value
                    tok = new SupportClass.Tokenizer(line, delim, false);
                    if (tok.HasMoreTokens())
                    {
                        key = tok.NextToken();
                    }
                    if (tok.HasMoreTokens())
                    {
                        value_Renamed = tok.NextToken();
                    }
                }
            }
            in_Renamed.Close();
        }
All Usage Examples Of SupportClass.Tokenizer::NextToken