gpt4 book ai didi

java - jreddit 返回意外结果

转载 作者:行者123 更新时间:2023-12-01 11:41:22 24 4
gpt4 key购买 nike

非常感谢!我开始工作了,

我发现的唯一问题是,当获取特定的评论 ID 时 提交后会返回分解的评论,

例如

Reddit reddit = new Reddit("USER","PASSWORD");
List<Submission> submissions = reddit.getSubmission(1); //returns 1 submission

for (Submission sub : submissions) {
System.out.println("BEGINNING OF SUBMISSION \n"+sub);
System.out.println(reddit.getCommentsForSubmission(sub.getIdentifier())); //prints out
System.out.println("END OF SUBMISSION \n");
}

此代码将仅打印第一个评论,如下所示..

开始提交提交(t3_31qc98)

enter image description here

结束运行

getCommentsForSubmission 看起来像这样......

public List<Comment> getCommentsForSubmission(String subId){

Comments coms = new Comments(getRestClient(), getUser());
List<Comment> commentsSubmission = coms.ofSubmission(subId, null, 0, 8, 20, CommentSort.TOP);
return commentsSubmission;
}

为什么 Jreddit 不打印整个评论?

最佳答案

jReddit/src/main/java/com/github/jreddit/entity/Comment.java 类具有以下 toString()

@Override
public String toString() {
return "Comment(" + identifier + ")<" + ((body.length() > 10) ? body.substring(0, 10) : body) + ">";
}

您可以调用获取完整评论:

comment.getBody();

问题是,您正在调用 System.out.println() ,它将自动调用方法内调用的当前对象的 toString()

关于java - jreddit 返回意外结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29498185/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com