Java method for replacing carriage return line feed in string

Replace with regular expression:

Code snippet:

String documentTxt = EntityUtils. toString(entity,"gbk");// Get data documentxt = documentxt replaceAll("[\\t\\n\\r]","");// Remove carriage returns and linefeeds from the content area

Note: replaceall of string class has regular replacement function. \T is tab character \ n is line feed \ R is carriage return

Java regular usage:

Example method:

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>