Java examples for Social Media:Twitter
Show Twitter public time line
import twitter4j.Status; import twitter4j.Twitter; import twitter4j.TwitterException; import twitter4j.TwitterFactory; import java.util.List; public class ShowPublicTimeline { public static void main(String[] args) { Twitter twitter = new TwitterFactory().getInstance(); try {/*from w ww. jav a2 s . co m*/ List<Status> statuses = twitter.getPublicTimeline(); for (Status status : statuses) { System.out.println("@" + status.getUser().getScreenName() + " - " + status.getText()); } System.exit(0); } catch (TwitterException te) { te.printStackTrace(); System.out.println(te.getMessage()); System.exit(-1); } } }