• 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

Appending values from textfield to CSV file

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have 2 TextFields and 2 combo boxes that I need to extract values from then append them to a csv file. So far I have the following code:



But only the "if (it.hasNext() == false)" works in my saveObject() method and I don't know why. Can somebody point out my mistake here? Also is there a better, more efficient way of solving this problem? Any help would be appreciated.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

But only the "if (it.hasNext() == false)" works in my saveObject() method and I don't know why.


What do you mean by that? What else is or is not working? What happens if you run the code, and how does that differ from what you expected?
 
Mickey Johnson
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hmm. When I run the program the output that comes out is "error" which is inside the "if (it.hasNext() == false)" but my while loop isn't executing. Okay so basically, my expected output is, I just want to save the values inside the fields and append them in a file but I have no idea how to do that, and I'm not even sure if my code is right.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If it.hasNext() returns false, why would you expect the while loop to execute?
 
Mickey Johnson
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Because I'm an idiot. Can I get any help towards solving this then?
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should move the line "Iterator it = list.iterator()" into the saveObject method; that should prevent the issue of the list being empty (or rather, the iterator working on an empty list) when you want to save it.
 
Mickey Johnson
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It works! Thank you!!
 
permaculture is a more symbiotic relationship with nature so I can be even lazier. Read tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic