Help coderanch get a
new server
by contributing to the fundraiser
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Reading a single value from a pipe delimited dat file

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Bras cause cancer. And tiny ads:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic