aspose file tools
The moose likes Java in General and the fly likes I want to tokenize a String?  How do I ignore the spaces? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "I want to tokenize a String?  How do I ignore the spaces?" Watch "I want to tokenize a String?  How do I ignore the spaces?" New topic
Author

I want to tokenize a String? How do I ignore the spaces?

Todd Vance
Greenhorn

Joined: Feb 28, 2007
Posts: 2
Hey guys,

I just finished a class in Java and am excited to make something fun like a trivia game with Swing. But I have come up against my first question - I learned to tokenize data in text files - but that was only on one piece of data.

Let me clarify - I know how to take a text file that has say 3 pieces of data per line, like: Towels 5.00 Housewares and tokeize that into 3 pieces of seperate data, BUT if I want to put 3 pieces of data for my trivia game like A) Question B) Answer and C) Point total I have problems because the QUESTION would have several spaces in it.

Can someone explain to me how I can make this work?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56153
    
  13

Hint: you can tokenize on characters other than spaces.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Todd Vance
Greenhorn

Joined: Feb 28, 2007
Posts: 2
Yep! I just found it... I can tokenize using Delimiters. That will be easy and will work perfect for me! Thanks a bunch!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56153
    
  13

When you really feel like diving in head first, you might consider using an XML format and parsing that. But that's probably a bit of a way down the road...
 
I agree. Here's the link: jrebel
 
subject: I want to tokenize a String? How do I ignore the spaces?
 
Similar Threads
creation of dynamic chessboard with user interactivity using javascript.
When to create an object...
projects that can be done in java
How make xs:List take a comma as delimiter?
Fontmetrics, Graphics