현재 Apache Commons Net을 사용하여 자체 NNTP 리더를 개발 중입니다. 사용 가능한 튜토리얼을 사용하여 코드를 사용하여 기사를 다시 얻을 수있었습니다.Apache Commons - NNTP - "Article To List"- AWT
강령은 내가 NNTP 섹션에서 사용하고 -
List x = (List) b.GetGroupList(dog);
f.add(CreateList(x));
-
System.out.println("Retrieving articles between [" + lowArticleNumber + "] and [" + highArticleNumber + "]");
Iterable<Article> articles = client.iterateArticleInfo(lowArticleNumber, highArticleNumber);
System.out.println("Building message thread tree...");
Threader threader = new Threader();
Article root = (Article)threader.thread(articles);
Article.printThread(root, 0);
나는 이런 식으로 뭔가를 사용하여 AWT 너무 내가 그들을 보낼 수있는 기사를 받아 목록 타입으로 만들어 놓을 필요 이 섹션
내 전체 코드베이스입니다 -
public void GetThreadList(String Search) throws SocketException, IOException {
String hostname = USE_NET_HOST;
String newsgroup = Search;
NNTPClient client = new NNTPClient();
client.addProtocolCommandListener(new PrintCommandListener(new PrintWriter(System.out), true));
client.connect(hostname);
client.authenticate(USER_NAME, PASS_WORD);
if(!client.authenticate(USER_NAME, PASS_WORD)) {
System.out.println("Authentication failed for user " + USER_NAME + "!");
System.exit(1);
}
String fmt[] = client.listOverviewFmt();
if (fmt != null) {
System.out.println("LIST OVERVIEW.FMT:");
for(String s : fmt) {
System.out.println(s);
}
} else {
System.out.println("Failed to get OVERVIEW.FMT");
}
NewsgroupInfo group = new NewsgroupInfo();
client.selectNewsgroup(newsgroup, group);
long lowArticleNumber = group.getFirstArticleLong();
long highArticleNumber = lowArticleNumber + 5000;
System.out.println("Retrieving articles between [" + lowArticleNumber + "] and [" + highArticleNumber + "]");
Iterable<Article> articles = client.iterateArticleInfo(lowArticleNumber, highArticleNumber);
System.out.println("Building message thread tree...");
Threader threader = new Threader();
Article root = (Article)threader.thread(articles);
Article.printThread(root, 0);
try {
if (client.isConnected()) {
client.disconnect();
}
}
catch (IOException e) {
System.err.println("Error disconnecting from server.");
e.printStackTrace();
}
}
와 -
public void CreateFrame() throws SocketException, IOException {
// Make a new program view
Frame f = new Frame("NNTP Reader");
// Pick my layout
f.setLayout(new GridLayout());
// Set the size
f.setSize(H_SIZE, V_SIZE);
// Make it resizable
f.setResizable(true);
//Create the menubar
f.setMenuBar(CreateMenu());
// Create the lists
UseNetController b = new UseNetController(NEWS_SERVER_CREDS);
String dog = "*";
List x = (List) b.GetGroupList(dog);
f.add(CreateList(x));
//f.add(CreateList(y));
// Add Listeners
f = CreateListeners(f);
// Show the program
f.setVisible(true);
}
반환 된 뉴스 기사 목록을 AWT의 디스플레이로 보내고 싶습니다. 어떤 기사가 그 기사들을 목록으로 만드는 법을 설명 할 수 있습니까?
1) 더 빨리 도움 들어 [SSCCE (http://sscce.org/)를 작성. 2) 클래스에 대한 일반적인 [Java 명명 규칙 (Java 命名 規則)] (http://java.sun.com/docs/books/books/books/jls/second_edition/html/names.doc.html#73307) (특히 이름에 사용 된 사례)을 배우십시오. , 메소드 및 속성 이름을 일관되게 사용하십시오. 3) Swing이 아닌 AWT를 사용해야하는 이유 AWT 구성 요소를 사용하여 포기해야하는 여러 가지 이유 때문에 [AWT를 통한 스윙 엑스트라] (http://stackoverflow.com/a/6255978/418556)에서이 대답을 참조하십시오. –
1. 확인. 2. 질문은 Apache Commons Library의 "Article"에 중점을 둡니다. 내 자신의 변수에 대한 x 또는 dog의 선택은 시간의 목적을위한 것입니다. 나중에 변경됩니다. "Article"은 아파치에서 나온다. 우리가 내 질문을 고칠 수 있다면 문제가된다면 변수 이름을 바꾸도록 이메일을 보내 줄 것이다. 3. http://www.pitman.co.za/projects/charva/index.html - AWT for Swing을 포기할 생각이 없습니다. charva를 사용할 수 있도록 AWT를 사용하려고합니다. – ILikeTurtles
다른 문제가 있습니다. 프로그램을 사용하려면 뉴스 서버 계정이 필요합니다. 그래서 업로드 할 수 있습니다. 자신의 뉴스 서버에 액세스 할 수있는 사람 만 프로그램을 실행할 수 있습니다. – ILikeTurtles