You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by hb...@apache.org on 2001/04/10 18:28:06 UTC

cvs commit: jakarta-james/src/org/apache/james/testing NNTPClient.java

hbedi       01/04/10 09:28:06

  Added:       src/org/apache/james/testing NNTPClient.java
  Log:
  NNTP Testing.
  Requires 2 parameters, nntp host and newsgroup name
  
  Revision  Changes    Path
  1.1                  jakarta-james/src/org/apache/james/testing/NNTPClient.java
  
  Index: NNTPClient.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE file.
   */
  package org.apache.james.testing;
  
  import java.util.*;
  import javax.mail.*;
  import javax.mail.internet.*;
  import sun.net.nntp.*;
  import org.apache.avalon.util.io.IOUtil;
  import java.io.*;
  
  /**
   * @author Harmeet <hb...@apache.org>
   */
  public class NNTPClient {
      public static void main(String[] args) throws Exception {
          String server = args[0];
          String group = args[1];
          NntpClient nntp = new NntpClient(server);
          NewsgroupInfo info = nntp.getGroup(group);
          System.out.println("newsgroup: "+group+", "+info.firstArticle+", "+
                             info.lastArticle);
          File f = new File(group);
          f.mkdirs();
          for ( int i = 0 ; i < 10 ; i++ ) {
              int articleId = i+info.firstArticle;
              if ( articleId > info.lastArticle )
                  break;
              IOUtil.copy(nntp.getArticle(articleId),
                          new FileOutputStream(new File(f,articleId+"")));
          }
      }
  }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: james-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: james-dev-help@jakarta.apache.org