简体   繁体   中英

how to replace the \n in java?

I have working in Facebook for my app in Android. I have to use the string to pass as a url. But my description value has a lot of spaces and line breaks. I have to rectify while passing that value as url without spaces. But it will poste on the facebook wall with the spaces. Is it possible? Any Idea.

生成URL参数时,请使用:

paramString = URLEncoder.encode(paramString, "utf-8");

I'm not sure if you're asking how to properly encode the URL so it has no whitespace, or if you want to remove line breaks from a string. If you want to remove line breaks from a string, do this:

yourString.replaceAll("\n", "");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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