public static int findEndTrimNewlineChars(CharSequence s){
  for (int i=s.length(); i > 0; ) {
    if (s.charAt(i - 1) != '\n') {
      return i;
    }
    i--;
    if (i > 0 && s.charAt(i - 1) == '\r') {
      i--;
    }
  }
  return 0;
}

public static int findEndTrimNewlineChars ( CharSequence s ) { for ( int i = s . length ( ) ; i > 0 ; ) { if ( s . charAt ( i - 1 ) != '\n' ) { return i ; } i -- ; if ( i > 0 && s . charAt ( i - 1 ) == '\r' ) { i -- ; } } return 0 ; }
finds and returns the end of the given character sequence after trimming new line characters from the right . the following character sequences are treated as newline characters : " \ n " , " \ r \ n " .
