Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12111

Convert a List to a CSV String with Headers

$
0
0

I hope someone can help with the following: I have an Arraylist of

List<Transaction> transactions; 

with fields:

private String firmId; private String accountId; private String symbol; private long quantity;

That I want to convert to the following CSV formatted String:

firmId,AccountId,symbol, quantity1234,ACCOUNT1,AAPL,1001234,ACCOUNT1,AMZN,2002345,ACCOUNT3,AAPL,400

Is there an efficient and simple way to do this in Java? As I don't want to use OpenCSV and write it to a file. I also don't like the option to use abstraction.

I need to use the CSVString in my program as a payload for another request. The number of objects can be up to 2000 in the List.

Thanks!


Viewing all articles
Browse latest Browse all 12111

Trending Articles