This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Java in General and the fly likes Creating a CSV File from a HashMap Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Creating a CSV File from a HashMap" Watch "Creating a CSV File from a HashMap" New topic
Author

Creating a CSV File from a HashMap

Bhanu Pratap
Greenhorn

Joined: Jun 16, 2005
Posts: 1
Hi,
I need to create a csv(Comma Separated Value) File from a given Hashmap.

one important thing here is the Hashmap may contain Vectors or Collection or object as Values and inturn those objects may contain Vectors or Collections and so on..

can anyone help me out in this.

Thanks in advance
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12268
    
    1
To iterate through the Hashmap you can either use the keySet or the values - it would depend on whether you need the keys to appear in the output.
You can use the instanceof operator to determine what the retrieved value object is and branch accordingly.

Exactly how anybody could interpret a CSV file created from such a motley collection is hard to imagine.

Bill


Java Resources at www.wbrogden.com
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Creating a CSV File from a HashMap
 
Similar Threads
Read data from an excel file to java file
Help Needed regarding reading the csv file
Approach to validate objects in list
Struts FormFile (parsing .csv files)
Reading a CSV file--> Fastest way