取一个字符串的前20个字符,保证不越界

content.substring(0, Math.min(content.length(), 20))

Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.