Tips for JAVA Split

Source: Internet
Author: User

String truncation is essential in daily development, but the Split Truncation in JAVA has some characteristics, such as: String str = 1, 2, 3; so str. split (","); the length after truncation is 3, but in some cases, such interception may cause trouble, such as String str = "1, XXX Road, XX Company, www. XXXX. COM, James, "// ID, address, company, URL, name, remarks in this case if you directly call str, split (","); the comment cannot be intercepted, but in the case that the remarks need to be assigned to a TextView, the comment will be out of the border because the length is 5, but the remarks are obviously in the 6th-bit format. How can this problem be solved? You only need to call str. split (",",-1); to solve the problem. After this is called, even if there is no data, a blank line is generated. If it is null, the string length is 0, not null

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.