1

If a particular String contains a newline character that is invisible (not \n but is 0A in hexadecimal because this value is passed down from the database), how can i able to chomp it away? Will Apache Chomp help?

http://commons.apache.org/lang/api-2.5/org/apache/commons/lang/StringUtils.html#chomp(java.lang.String)

The hex form of the text returned from the database is "5761 6920 4D61 6E0D 0A"

It translates to "Wai Man" with a carriage return.

Oh Chin Boon
  • 23,028
  • 51
  • 143
  • 215

2 Answers2

5

You can use a regular expression

String text = "Hello\r\nThere\r\n";
String shortText = text.replaceAll("\r", "");
Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130
0

This is what I did and it worked for me:

input_data.replaceAll("\\xC2"," ").replaceAll("\\xA0"," ")
Procrastinator
  • 2,526
  • 30
  • 27
  • 36