• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

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

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Author and ninkuma
Marshal
Posts: 66823
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hint: you can tokenize on characters other than spaces.
 
Todd Vance
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 66823
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!