• 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 up to the first delimiter and then moving on to next line.

 
Ranch Hand
Posts: 46
  • 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 that has contents as follows:

testing1,true,0,0.0,0,0.0,4.0,0.0,0.0,0.0,0.0
test2,true,0,0.0,0,0.0,4.0,0.0,0.0,0.0,0.0

I am trying to read only the first item in each list using a comma as a delimiter using the following code.



At line 16, with nextLine, I get the following in a drop down menu:

testing1,true,0,0.0,0,0.0,4.0,0.0,0.0,0.0,0.0
test2,true,0,0.0,0,0.0,4.0,0.0,0.0,0.0,0.0

If I change line 16 to next(), i get the following example:

testing1
true
0
0.0
0
4.0 and so on

I've taken a look around, but not really finding the solution. I know I am probably missing something simple and I'm probably going to slap my forehead once the mistake is revealed, but what am I missing, doing wrong?

 
Jenn Terry
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I feel dumb!

Solution:



Solution was simply adding one line to advance to next line and fixing a small error in the while loop.

Thanks anyways for taking a look guys.
 
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Don't worry we've all had those Doh!! moments. And thanks for updating the thread with the solution.
 
reply
    Bookmark Topic Watch Topic
  • New Topic