我目前正在尝试开发一个在nntp服务器上检索文章的简单软件。我在apache.commons.net上使用NNTPClient。
当我检索文章的所有片段时,片段比预期的要长,我无法使用yDec soft(like this one)对它们进行解码(并mer他们)。
这是我的代码,它下载段并将其写在硬盘上:
BufferedReader br;
String line;
List<File> files = new ArrayList<File>();
for(NzbSegment s : segments) {
String str = s.getMessageID();
br = (BufferedReader) client.retrieveArticleBody("<" + str + ">");
String filePath = fileName + "-" + s.getSegmentNumber() +"body.yenc";
File f = new File(filePath);
f.delete(); //Make sure we have a new clean file
f = new File(filePath);
int bytes = 0;
while ((line = br.readLine()) != null) {
FileUtils.writeStringToFile(f,line + "\n",true);
bytes += line.getBytes().length;
}
System.out.println("size : " + s.getBytes() + " compare to : " + bytes);
br.close();
files.add(f);
}
使用POJO NzbSegment:
public class NzbSegment {
private int bytes;
private int segmentNumber;
private String messageID;}
你知道我错在哪里吗?