This tip shows how to send a message on a news server using NNTP protocol.

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

public class NntpPost {
  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]);
    NewsgroupInfo ni = c.getGroup("alt.test");
    PrintStream p = c.startPost();
    System.out.println("Starting post at " + args[0] + "...");
    p.println("From: This email address is being protected from spambots. You need JavaScript enabled to view it. (Elvis Presley)");
    p.println("Newsgroups: alt.test");
    p.println("Subject: I'm alive");
    p.println("");
    p.println("Hi");
    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");
    else
      System.out.println("Ending post... failed");
    c.closeServer();
    }
  }