Internetmusic with Java

A small group on twitter started a funny (or stupid?) mem #internetmusiker (which is internet-musician in English). The initial idea came from FR31H31T. The task was to slightly change a name of a musician, band or song and get a phrase which sounds like an internet- or computer-technical phrase. The results were sometimes very funny and my favourite examples are:

Nine inch Mails, Modem Talking, Deftunes, Wii valdi oder iValdi and Sudo Lindenberg

Look here for the full list!

Now I wanted to know which phrases were the most retweeted once and I wrote a small Java application which uses the twitter4j API to do this task.

Twitter twitter = new Twitter(login, pw);
for (int page = 1; page < 1500; page++) {
 Query query = new Query("internetmusiker");

 try {
   QueryResult res =;
   if (res.getTweets().size() == 0) {
     log("No more tweets found");
   log("page:" + page + " found " + res.getTweets().size() + " tweets");
   for (Tweet twe : res.getTweets()) {
 } catch (TwitterException ex) {
   log("End of search reached", ex);

To avoid a full search for the next time I saved the results via my small helper object StoreableTweet to a text file and used ‘query.setSinceId(maxId);’ while querying.

To calculate the retweets there is no API provided (or am I wrong?) so I needed to parse for a ‘RT @name text’ and look up the text within all the tweets. For that I created a hash map with the text content as keys.

 Map<String, StorableTweet> mappedTweets = new HashMap();

 for (StorableTweet stw : allTweets) {
   String key = stw.getTextToRetweet();
   if (mappedTweets.containsKey(key))
     log("Mapped tweets collection already contains tweet:"
         + stw.toPersistentString());

   mappedTweets.put(key, stw);

 for (StorableTweet stw : allTweets) {
   if (stw.getOrigRetweetedText().length() > 0) {
     StorableTweet retweet = mappedTweets.get(
     if (retweet == null)
       log("Skip retweet: cannot find retweet "
          + stw.toPersistentString());

Again you can look here for the resulting html file. So start your own with #internetmusiker oder even #internetmusician?


One thought on “Internetmusic with Java

Comments are closed.