0

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 ,

E.g

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)

enter image description here

END RUN

getCommentsForSubmission looks like this…

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?

Andrei Sfat
  • 8,440
  • 5
  • 49
  • 69
stringRay2014
  • 636
  • 1
  • 11
  • 29

1 Answers1

1

jReddit/src/main/java/com/github/jreddit/entity/Comment.java class has the folowing 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.

Andrei Sfat
  • 8,440
  • 5
  • 49
  • 69