Results 1 to 2 of 2

Thread: StringTokenizer

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2001
    Location
    Jutland, Denmark
    Posts
    71

    StringTokenizer

    I have this code
    st = new StringTokenizer(line, " \n\t\r\'\",;()-.");
    while(st.hasMoreTokens())
    {
    try
    {
    temp= st.nextToken();;
    word++;
    System.out.println(temp);
    if (temp.length() >= 7)
    {
    l_word++;
    System.out.println("lang "+temp+ ":"+l_word);
    }
    are there any way to check if the delimiters are - to example .
    and then count++ or have i to make a new loop

  2. #2
    Addicted Member
    Join Date
    Nov 2001
    Location
    Yewston, Texis
    Posts
    240
    try:
    st = new StringTokenizer(line, " \n\t\r\'\",;()-.", true);

    Then your delimiters themselves will be returned as well as your delimited text.

    cudabean

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width