Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (102)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (322)
Collections:
Other Resources:
commons-net-1.4.1.jar - Apache Commons Net
commons-net-1.4.1.jar is the JAR file for Apache Commons Net 1.4.1, which
implements the client side of many basic Internet protocols.
commons-net-1.4.1.jar is distributed as part of the commons-net-1.4.1.zip download file.
JAR File Size and Download Location:
JAR name: commons-net.jar, commons-net-1.4.1.jar Target JDK version: 1.4 Dependency: None File name: commons-net-1.4.1.jar File size: 180792 bytes Date modified: 03-Dec-2005 Download: Apache Commons Net
✍: FYIcenter.com
⏎ examples/nntp/NNTPUtils.java
package examples.nntp;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.Reader;
import java.util.StringTokenizer;
import org.apache.commons.net.io.DotTerminatedMessageReader;
import org.apache.commons.net.nntp.Article;
import org.apache.commons.net.nntp.NNTPClient;
/**
*
* Some convenience methods for NNTP example classes.
*
* @author Rory Winston <rwinston@checkfree.com>
*/
public class NNTPUtils {
/**
* Given an {@link NNTPClient} instance, and an integer range of messages, return
* an array of {@link Article} instances.
* @param client
* @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;
}
/**
* Convert a {@link Reader} instance to a String
* @param reader The Reader instance
* @return String
*/
public static String readerToString(Reader reader) {
String temp = null;
StringBuffer sb = null;
BufferedReader bufReader = new BufferedReader(reader);
sb = new StringBuffer();
try {
temp = bufReader.readLine();
while (temp != null) {
sb.append(temp);
sb.append("\n");
temp = bufReader.readLine();
}
} catch (IOException e) {
e.printStackTrace();
}
return sb.toString();
}
}
⏎ examples/nntp/NNTPUtils.java
Or download all of them as a single archive file:
File name: commons-net-1.4.1-src.zip File size: 324370 bytes Release date: 2013-03-03 Download
⇒ Using commons-net.jar in Java Programs
⇐ What Is commons-net-ftp-2.0.jar
2015-06-03, ≈113🔥, 0💬
Popular Posts:
jlGui is a music player for the Java platform. It is based on Java Sound 1.0 (i.e. JDK 1.3+). It sup...
JDK 11 java.rmi.jmod is the JMOD file for JDK 11 RMI (Remote Method Invocation) module. JDK 11 RMI m...
JLayer is a library that decodes/plays/converts MPEG 1/2/2.5 Layer 1/2/3 (i.e. MP3) in real time for...
Where to get the Java source code for Connector/J 8.0 Core API module? Java source code files for Co...
What Is poi-3.5.jar - Part 2? poi-3.5.jar is one of the JAR files for Apache POI 3.5, which provides...