public static String convertEOLToLF(String input){
  StringBuilder res=new StringBuilder(input.length());
  char[] s=input.toCharArray();
  int from=0;
  final int end=s.length;
  for (int i=0; i < end; i++) {
    if (s[i] == '\r') {
      res.append(s,from,i - from);
      res.append('\n');
      if (i + 1 < end && s[i + 1] == '\n') {
        i++;
      }
      from=i + 1;
    }
  }
  if (from == 0) {
    return input;
  }
  res.append(s,from,end - from);
  return res.toString();
}

public static String convertEOLToLF ( String input ) { StringBuilder res = new StringBuilder ( input . length ( ) ) ; char [ ] s = input . toCharArray ( ) ; int from = 0 ; final int end = s . length ; for ( int i = 0 ; i < end ; i ++ ) { if ( s [ i ] == '\r' ) { res . append ( s , from , i - from ) ; res . append ( '\n' ) ; if ( i + 1 < end && s [ i + 1 ] == '\n' ) { i ++ ; } from = i + 1 ; } } if ( from == 0 ) { return input ; } res . append ( s , from , end - from ) ; return res . toString ( ) ; }
converts any instances of " \ r " or " \ r \ n " style eols into " \ n " ( line feed ) .
