|
Post a message on a news server using NNTP protocol |
|
|
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 e-mail address is being protected from spam bots, 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();
}
}
|
Related Tips
|
Page 1 of 0 ( 0 comments )
You can share your information about this topic using the form below!
Please do not post your questions with this form! Thanks.