Use StringUtils.chomp( )
to remove the last line termination sequence from a string:
String input = "Hello\n";
String chomped = StringUtils.chomp( input );
// chomped equals "Hello"
String input2 = "Another test\r\n";
String chomped2 = StringUtils.chomp( input2 );
// chomped2 equals "Another test";