开发者

how to replace the \n in java?

开发者 https://www.devze.com 2023-01-03 08:53 出处:网络
I have working in Facebook for my app in Android. I have to use the string to pass as a url. Bu开发者_JAVA技巧t my description value has a lot of spaces and line breaks. I have to rectify while passin

I have working in Facebook for my app in Android. I have to use the string to pass as a url. Bu开发者_JAVA技巧t 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.


When generating your URL parameters, use:

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", "");
0

精彩评论

暂无评论...
验证码 换一张
取 消