Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Reading a single value from a pipe delimited dat file

 
rastas biggs
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a text file in need to get a value from in this case

0409531354|False|Residential

How do I get the value I want from the file like the boolean value false

I can read the file ok but what implimentation is available to scan the value I'm after







Does someone have some example code

RB
[ November 03, 2004: Message edited by: rastas biggs ]
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're in a good place after reading a whole line. If you're in JDK 1.4 or later, check the JavaDoc for String.split(). That will give you an array of strings, one for each segment of your line. If you're in an earlier JDK, look at StringTokenizer. That will let you fetch one segment at a time.

Be sure to test your code with missing values like: 0409531354||Residential

Hope that helps!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic