Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Every token to a string?

  1. #1
    Junior Member
    Join Date
    Mar 2011
    Location
    Sweden
    Posts
    2
    My Mood
    Nerdy
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post Every token to a string?

    Hi, I started making a program and now I have problem... Quite obvious...
    Well, I wonder if you can make every token using StringTokenizer to a new string.
    If someone could help quick it would be nice.

    Thanks
    //Hjorth96


  2. #2
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: Every token to a string?

    Use String.spilt instead.

  3. #3
    Junior Member
    Join Date
    Mar 2011
    Location
    Sweden
    Posts
    2
    My Mood
    Nerdy
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Every token to a string?

    Will that split the whole sentence in the first string up in words? I want to make every word from that to a new string.

  4. #4
    Junior Member
    Join Date
    Mar 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Every token to a string?

    If the words are separated by spaces and you split around spaces you'll get an array of words.

    E.g. if we have:
    String example = "This is an example string. What do you think?";
    String[] tokens = example.split(" ");

    Then tokens will be an array of strings
    ["This","is","an","example","string.","What","do"," you","think?"]

    You could further clean it up to remove non-alphabetical characters and change the case.

Similar Threads

  1. Syntax error on token ";", @ expected after this token
    By MagicMojo in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 16th, 2011, 07:48 AM
  2. Replies: 18
    Last Post: March 2nd, 2011, 10:52 AM
  3. [SOLVED] String Matcher finding only char not a whole string
    By Kakashi in forum What's Wrong With My Code?
    Replies: 11
    Last Post: February 18th, 2011, 09:58 AM
  4. Getting length of individual token?
    By Kimimaru in forum What's Wrong With My Code?
    Replies: 10
    Last Post: February 10th, 2011, 02:48 AM
  5. token-based processing
    By amandat in forum What's Wrong With My Code?
    Replies: 0
    Last Post: October 21st, 2010, 12:05 AM