简体   繁体   English

jreddit返回意外结果

[英]jreddit returning unexpected results

Thanks a lot ! 非常感谢 ! I got in working , 我上班了

The only problem I found is that when getting the comment id for the specific submission it returns broken up comments , 我发现的唯一问题是,当获取特定提交的评论ID时,它将返回分解的评论,

Eg 例如

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");
    }

This code will print only the first comment which look like this .. 此代码将仅打印如下所示的第一个注释。

BEGINNING OF SUBMISSION Submission(t3_31qc98) 提交开始(t3_31qc98)

在此处输入图片说明

END RUN 结束运行

getCommentsForSubmission looks like this… 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;
}

Why doesn't Jreddit print out the whole comment? Jreddit为什么不打印全部评论?

jReddit/src/main/java/com/github/jreddit/entity/Comment.java class has the folowing toString() 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) + ">";
}  

You could potentially make a call to get the full comment: 您可以致电以获取完整评论:

comment.getBody();

The thing is that you are calling System.out.println() which would call automatically the toString() of the current object being called inside the method. 事实是,您正在调用System.out.println() ,该方法将自动调用在方法内部被调用的当前对象的toString()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM