NNTPClient client;
NewsgroupInfo[] list;
if (args.length < 1)
{
System.err.println("Usage: newsgroups newsserver");
System.exit(1);
}
client = new NNTPClient();
try
{
client.connect(args[0]);
list = client.listNewsgroups();
if (list != null)
{
for (int i = 0; i < list.length; i++)
System.out.println(list[i].getNewsgroup());
}
else
{
System.err.println("LIST command failed.");
System.err.println("Server reply: " + client.getReplyString());
}
}
catch (IOException e)
{
e.printStackTrace();
}
finally
{
try
{
if (client.isConnected())
client.disconnect();
}
catch (IOException e)
{
System.err.println("Error disconnecting from server.");
e.printStackTrace();
System.exit(1);
}
}