List of usage examples for org.apache.commons.net.nntp Article addHeaderField
@Deprecated public void addHeaderField(String name, String val)
From source file:Main.java
/** * Given an {@link NNTPClient} instance, and an integer range of messages, return * an array of {@link Article} instances. * @param client /*from ww w .j a v a 2 s .c o m*/ * @param lowArticleNumber * @param highArticleNumber * @return Article[] An array of Article * @throws IOException */ public static Article[] getArticleInfo(NNTPClient client, int lowArticleNumber, int highArticleNumber) throws IOException { Reader reader = null; Article[] articles = null; reader = (DotTerminatedMessageReader) client.retrieveArticleInfo(lowArticleNumber, highArticleNumber); if (reader != null) { String theInfo = readerToString(reader); StringTokenizer st = new StringTokenizer(theInfo, "\n"); // Extract the article information // Mandatory format (from NNTP RFC 2980) is : // Subject\tAuthor\tDate\tID\tReference(s)\tByte Count\tLine Count int count = st.countTokens(); articles = new Article[count]; int index = 0; while (st.hasMoreTokens()) { StringTokenizer stt = new StringTokenizer(st.nextToken(), "\t"); Article article = new Article(); article.setArticleNumber(Integer.parseInt(stt.nextToken())); article.setSubject(stt.nextToken()); article.setFrom(stt.nextToken()); article.setDate(stt.nextToken()); article.setArticleId(stt.nextToken()); article.addHeaderField("References", stt.nextToken()); articles[index++] = article; } } else { return null; } return articles; }
From source file:org.ossmeter.platform.communicationchannel.nntp.local.NntpUtil.java
public static Article[] getArticleInfo(NNTPClient nntpClient, int startArticleNumber, int endArticleNumber) throws IOException { Reader reader = null;/*from w ww . j a va 2 s .c o m*/ Article[] articles = null; reader = (DotTerminatedMessageReader) nntpClient.retrieveArticleInfo(startArticleNumber, endArticleNumber); if (reader != null) { String theInfo = readerToString(reader); StringTokenizer st = new StringTokenizer(theInfo, "\n"); // Extract the article information // Mandatory format (from NNTP RFC 2980) is : // Subject\tAuthor\tDate\tID\tReference(s)\tByte Count\tLine Count int count = st.countTokens(); articles = new Article[count]; int index = 0; while (st.hasMoreTokens()) { StringTokenizer stt = new StringTokenizer(st.nextToken(), "\t"); Article article = new Article(); article.setArticleNumber(Integer.parseInt(stt.nextToken())); article.setSubject(decodeSubject(stt.nextToken())); article.setFrom(stt.nextToken()); article.setDate(stt.nextToken()); article.setArticleId(stt.nextToken()); article.addHeaderField("References", stt.nextToken()); articles[index++] = article; } } else { return null; } return articles; }