• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Appending values from textfield to CSV file

 
Mickey Johnson
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • 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.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • 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
  • 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: 42968
73
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Because I'm an idiot. Can I get any help towards solving this then?
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
It works! Thank you!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic