List of usage examples for org.apache.commons.net.nntp NNTPClient retrieveArticleBody
@Deprecated public Reader retrieveArticleBody(int a) throws IOException
From source file:examples.nntp.ArticleReader.java
public static void main(String[] args) throws SocketException, IOException { if (args.length != 2 && args.length != 3 && args.length != 5) { System.out.println(// w ww .j a va 2s .c om "Usage: MessageThreading <hostname> <groupname> [<article specifier> [<user> <password>]]"); return; } String hostname = args[0]; String newsgroup = args[1]; // Article specifier can be numeric or Id in form <m.n.o.x@host> String articleSpec = args.length >= 3 ? args[2] : null; NNTPClient client = new NNTPClient(); client.addProtocolCommandListener(new PrintCommandListener(new PrintWriter(System.out), true)); client.connect(hostname); if (args.length == 5) { // Optional auth String user = args[3]; String password = args[4]; if (!client.authenticate(user, password)) { System.out.println("Authentication failed for user " + user + "!"); System.exit(1); } } NewsgroupInfo group = new NewsgroupInfo(); client.selectNewsgroup(newsgroup, group); BufferedReader br; String line; if (articleSpec != null) { br = (BufferedReader) client.retrieveArticleHeader(articleSpec); } else { long articleNum = group.getLastArticleLong(); br = client.retrieveArticleHeader(articleNum); } if (br != null) { while ((line = br.readLine()) != null) { System.out.println(line); } br.close(); } if (articleSpec != null) { br = (BufferedReader) client.retrieveArticleBody(articleSpec); } else { long articleNum = group.getLastArticleLong(); br = client.retrieveArticleBody(articleNum); } if (br != null) { while ((line = br.readLine()) != null) { System.out.println(line); } br.close(); } }
From source file:org.apache.commons.net.examples.nntp.ArticleReader.java
public static void main(String[] args) throws SocketException, IOException { if (args.length != 2 && args.length != 3 && args.length != 5) { System.out.println(/*from w ww. ja va 2 s. c o m*/ "Usage: MessageThreading <hostname> <groupname> [<article specifier> [<user> <password>]]"); return; } String hostname = args[0]; String newsgroup = args[1]; // Article specifier can be numeric or Id in form <m.n.o.x@host> String articleSpec = args.length >= 3 ? args[2] : null; NNTPClient client = new NNTPClient(); client.addProtocolCommandListener(new PrintCommandListener(new PrintWriter(System.out), true)); client.connect(hostname); if (args.length == 5) { // Optional auth String user = args[3]; String password = args[4]; if (!client.authenticate(user, password)) { System.out.println("Authentication failed for user " + user + "!"); System.exit(1); } } NewsgroupInfo group = new NewsgroupInfo(); client.selectNewsgroup(newsgroup, group); BufferedReader brHdr; String line; if (articleSpec != null) { brHdr = (BufferedReader) client.retrieveArticleHeader(articleSpec); } else { long articleNum = group.getLastArticleLong(); brHdr = client.retrieveArticleHeader(articleNum); } if (brHdr != null) { while ((line = brHdr.readLine()) != null) { System.out.println(line); } brHdr.close(); } BufferedReader brBody; if (articleSpec != null) { brBody = (BufferedReader) client.retrieveArticleBody(articleSpec); } else { long articleNum = group.getLastArticleLong(); brBody = client.retrieveArticleBody(articleNum); } if (brBody != null) { while ((line = brBody.readLine()) != null) { System.out.println(line); } brBody.close(); } }
From source file:org.ossmeter.platform.communicationchannel.nntp.local.NntpUtil.java
public static String getArticleBody(NNTPClient client, int articleNumber) throws IOException { String articleBody = null;/*from ww w .j a v a2 s. c o m*/ Reader reader = (DotTerminatedMessageReader) client.retrieveArticleBody(articleNumber); if (reader != null) { articleBody = readerToString(reader); } else { return articleBody; } return articleBody; }