File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes How collection.toArray() works? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How collection.toArray() works?" Watch "How collection.toArray() works?" New topic

How collection.toArray() works?

mohan kumar

Joined: Apr 16, 2007
Posts: 11
Hi friends,
In my workspace i am facing a problem.
In my java code i have a collection which contains the data like
Account No, Account Type, Currency, Transaction Date, Transaction Id, Channel Description, Description, Debit Amount, Credit Amount
I want this data to be exported to CSV format.So i created a out stream.I changed the collection to array.Now i want to iterate the array and create a CSV file in the above mentioned format.I don't know how to do that.

Kindly help me in this issue.

David O'Meara

Joined: Mar 06, 2001
Posts: 13459

Did you want to show us what you have so far?
(not your entire application, mind you, just the important bits)
Krishnan Loganathan

Joined: Apr 24, 2004
Posts: 23
Hi Mohan,

Are you storing the data inside an Object and then add that object in the Collection or adding the data in comma seperated format as a String ?. Please clarify me.

Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023

It's not clear to me which part of this task you're stuck on.

If you're unfamiliar with working with arrays in Java, part 9 of Bradly Kjell's "Introduction to Computer Science using Java" includes good lessons and practice exercises to help learn the subject.

If you're not yet comfortable writing data to a text file, chapters 82, 83 and 87 in part 13 of Kjell's lessons cover the subject well.

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
mohan kumar

Joined: Apr 16, 2007
Posts: 11
thanks guys...and Mr.Dirk Schreckmann link helped me a lot...
I agree. Here's the link:
subject: How collection.toArray() works?
It's not a secret anymore!