import sun.net.nntp.*; import java.io.*; public class PostNews { public static void main(String[] args) { String server = "news"; String newsgroup = "inch.test"; try { NntpClient nc = new NntpClient(server); nc.setGroup(newsgroup); OutputStream os = nc.startPost(); if (os != null) { PrintStream p = new PrintStream(os); p.println("From: elharo@sunsite.unc.edu (Elliotte Harold)"); p.println("Newsgroups: inch.test"); p.println("Subject: Usenet Etiquette -- Please Read"); p.println("Followup-To: inch.test"); p.println("Organization: Java Secrets"); p.println(""); p.println("The body of the article comes here, after a blank line."); if (nc.finishPost()) { System.err.println("Success!"); } else System.err.println("Failure"); } else System.err.println("Posting not allowed"); } catch (IOException e) { System.err.println(e); } } }