cancel
Showing results for 
Search instead for 
Did you mean: 

replacing \n an \t by blank spaces

Former Member
0 Kudos

Hi Experts,

In a string how to replace \n(newline) and \t(tab) by a space in " " webdynpro .

it is not replacing for me by using replaceAll("\n"," ");

Regards

Rohan Henry

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

This is not Web Dynpro specific.


	static String replace(String s)
	{
		StringBuffer result = new StringBuffer(s);
		for (int i = 0; i < s.length(); ++i)
		{
			char c = s.charAt(i);
			switch (c)
			{
			case '\n':
			case '\t':
				result.setCharAt(i, ' ');
				break;
			default:
				break;
			}
		}
		return result.toString();
	}

Armin