aspose file tools*
The moose likes Beginning Java and the fly likes Appending values from textfield to CSV file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Appending values from textfield to CSV file" Watch "Appending values from textfield to CSV file" New topic
Author

Appending values from textfield to CSV file

Mickey Johnson
Greenhorn

Joined: Sep 30, 2013
Posts: 4
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
Marshal

Joined: Mar 22, 2005
Posts: 42951
    
  72
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

Joined: Sep 30, 2013
Posts: 4
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
Marshal

Joined: Mar 22, 2005
Posts: 42951
    
  72
If it.hasNext() returns false, why would you expect the while loop to execute?
Mickey Johnson
Greenhorn

Joined: Sep 30, 2013
Posts: 4
Because I'm an idiot. Can I get any help towards solving this then?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42951
    
  72
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

Joined: Sep 30, 2013
Posts: 4
It works! Thank you!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Appending values from textfield to CSV file