0

非常感谢 !我上班了,

我发现的唯一问题是,在获取特定提交的评论 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)

在此处输入图像描述

结束运行

getCommentsForSubmission 看起来像这样……</p>

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 不打印出整个评论?

4

1 回答 1

1

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()调用在方法内部被调用的当前对象的。

于 2015-05-12T13:04:18.297 回答