commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1080832 - /commons/proper/net/trunk/src/main/java/examples/nntp/NNTPUtils.java
Date Sat, 12 Mar 2011 01:04:10 GMT
Author: sebb
Date: Sat Mar 12 01:04:10 2011
New Revision: 1080832

URL: http://svn.apache.org/viewvc?rev=1080832&view=rev
Log:
Simplify

Modified:
    commons/proper/net/trunk/src/main/java/examples/nntp/NNTPUtils.java

Modified: commons/proper/net/trunk/src/main/java/examples/nntp/NNTPUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/examples/nntp/NNTPUtils.java?rev=1080832&r1=1080831&r2=1080832&view=diff
==============================================================================
--- commons/proper/net/trunk/src/main/java/examples/nntp/NNTPUtils.java (original)
+++ commons/proper/net/trunk/src/main/java/examples/nntp/NNTPUtils.java Sat Mar 12 01:04:10
2011
@@ -16,9 +16,7 @@
  */
 package examples.nntp;
 
-import java.io.BufferedReader;
 import java.io.IOException;
-import java.io.Reader;
 import java.util.ArrayList;
 import java.util.List;
 import org.apache.commons.net.nntp.Article;
@@ -43,33 +41,12 @@ public class NNTPUtils {
      */
     public  static List<Article> getArticleInfo(NNTPClient client, long lowArticleNumber,
long highArticleNumber)
     throws IOException {
-        Reader reader = null;
         List<Article> articles = new ArrayList<Article>();
-        reader = client.retrieveArticleInfo(
-                    lowArticleNumber,
-                    highArticleNumber);
-
-        if (reader != null) {
-            BufferedReader bufReader = new BufferedReader(reader);
-
-            // Extract the article information
-            // Mandatory format (from NNTP RFC 2980) is :
-            // articleNumber\tSubject\tAuthor\tDate\tID\tReference(s)\tByte Count\tLine Count
-
-            String msg;
-            while ((msg=bufReader.readLine()) != null) {
-                System.out.println("Message:" + msg);
-                String parts[] = msg.split("\t");
-                if (parts.length > 6) {
-                    int i = 0;
-                    Article article = new Article();
-                    article.setArticleNumber(Integer.parseInt(parts[i++]));
-                    article.setSubject(parts[i++]);
-                    article.setFrom(parts[i++]);
-                    article.setDate(parts[i++]);
-                    article.setArticleId(parts[i++]);
-                    article.addReference(parts[i++]);
-                    articles.add(article);
+        Iterable<Article> arts = client.iterateArticleInfo(lowArticleNumber, highArticleNumber);
+        if (arts != null) {
+            for(Article article : arts){
+                if (article != null ) {
+                    articles.add(article);                
                 }
             }
         }



Mime
View raw message