Praveen
Praveen

Reputation: 91175

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.

Upvotes: 0

Views: 5443

Answers (2)

Bozho
Bozho

Reputation: 597096

When generating your URL parameters, use:

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

Upvotes: 6

Jeff
Jeff

Reputation: 21892

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

Upvotes: 2

Related Questions