I'm using twitter4j to extract tweets from twitter. After i use this line i get a json result:
QueryResult result = twitter.search(query);
I want to know how to use opencsv to write this into csv. writeAll() is only for List or result set, I want to know what i can do with my query result. Many thanks!
I don't think you can use writeAll()
directly, as you'll need to build a List<String[]>
beforehand.
Alternatively you could use CSVWriter#writeNext(String[])
to write individual Tweets whilst iterating through QueryResult#getTweets()
, for example:
for (final Status status : result.getTweets())
{
final String[] line = new String[] { Long.toString(status.getId()), status.getText(), ... };
writer.writeLine(line);
}