Share this page 

Post a message on a newsserver using NNTP protocol (this howto is deprecated)Tag(s): DEPRECATED

This snippet uses an undocumented Sun package [JDK1.1]

public class NntpPost {
  public static void main(String[] args) throws IOException {
    ** pass your news server as parameter 
    **     eg. java NttpPost
    NntpClient c = new NntpClient(args[0]);
    NewsgroupInfo ni = c.getGroup("alt.test");
    PrintStream p = c.startPost();
    System.out.println("Starting post at " + args[0] + "...");
    p.println("From: epresley@jailhouse.rock (Elvis Presley)");
    p.println("Newsgroups: alt.test");
    p.println("Subject: I'm alive");
    p.println("Don't be cruel, please help me");
    p.println(" ");
    p.println("Thanks in advance");
    if (c.finishPost())
      System.out.println("Ending post... success");
      System.out.println("Ending post... failed");

Here some java code to illustrate NTTP protocol without using the undocumented classes, Communicating with an NNTP server.

Sun's JavaMail APi can be used to interact with a NTTP server, check out the Knife Plugin.