How can I get a list of newsgroups on my NNTP server?

John Zukowski

The non-standard sun.net.nntp.NntpClient class lets you get this information.

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

public class ListGroups {
  public static void main(String args[]) throws Exception {
    String server = args[0];
    NntpClient nc = new NntpClient(server);
    String line;
    nc.serverOutput.println("list newsgroups");
    BufferedReader br = 
      new BufferedReader(
        new InputStreamReader(nc.serverInput));
    while ((line = br.readLine()) != null) {
      if (line.equals(".")) break;
0 Comments  (click to add your comment)
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



About | Sitemap | Contact