This tip shows a way to obtain the list of headers from a newsgroup.

 import sun.net.nntp.*;
import java.io.*;

public class NntpHeader {
  public static void main(String[] args) 
    throws IOException {
    /*
    ** pass your news server as parameter 
    **     eg. java NttpPost news.server.com
    */
    NntpClient c = new NntpClient(args[0]);
    String newsgroup = "alt.test";
    c.setGroup(newsgroup);
    NewsgroupInfo ni = c.getGroup(newsgroup);
    int first = ni.firstArticle;
    int last = ni.lastArticle;
    for (int i = first; i <= last; i++) {
      try { 
        InputStream theHeader = c.getHeader(i);
        BufferedReader br = new BufferedReader(new 
           InputStreamReader(theHeader));
        String theLine;
        System.out.println("-----------------\nHeader " + i + "/" + last);
        while ((theLine = br.readLine()) != null) 
        System.out.println(theLine);
        }
      catch (NntpProtocolException ne) {
        /* 
        ** probably a cancelled article, just skip it
        */
        }
      }
    }
  }