0

我正在使用 twitter4j 从 twitter 中提取推文。我想知道在检索推文后,如何将这些推文写入 csv 文件?非常感谢!

 package test;
    import twitter4j.*;
    import twitter4j.conf.ConfigurationBuilder;
    import java.io.IOException;
    import java.sql.*;
    import java.util.Calendar;
    import java.io.FileWriter;
    public class test {
        public static void main(String[] args) throws TwitterException, IOException, ClassNotFoundException, IllegalAccessException, InstantiationException, SQLException 
        {
            ConfigurationBuilder cb = new ConfigurationBuilder();
            cb.setDebugEnabled(true)
                    .setOAuthConsumerKey("XXX")
                    .setOAuthConsumerSecret("XXX")
                    .setOAuthAccessToken("XX")
                    .setOAuthAccessTokenSecret("XX");
            TwitterFactory tf = new TwitterFactory(cb.build());
            Twitter twitter = tf.getInstance();
            Query query = new Query("your keywords");
            query.setCount(200);
            query.geoCode(new GeoLocation(XX, XXX), 200, Query.KILOMETERS);
            QueryResult result = twitter.search(query);
    }
    }
4

1 回答 1

0

我发现OpenCSV是一个优秀的 Java CSV 库。它是开源的并且在 Maven Central 中

于 2013-06-28T03:41:44.650 回答