code: public static String guessLineTerminatorOfFile(String _file) {
          if (StringUtil.isEmpty(_file)) {
              return SystemUtil.LINE_SEPARATOR;
          }
  
          File file = new File(_file);
          if (!file.exists() || !file.canRead()) {
              return SystemUtil.LINE_SEPARATOR;
          }
  
          try (BufferedReader reader = new BufferedReader(new FileReader(file))){
              boolean carriageReturn = false;
              boolean lineFeed = false;
              boolean nextIteration = false;
  
              char[] buf = new char[1];
              while (reader.read(buf) != -1) {
  
                  if (buf[0] == '\r') {
                      carriageReturn = true;
                  } else if (buf[0] == '\n') {
                      lineFeed = true;
                  }
  
                  // found both, must be DOS/windows like separators
                  if (carriageReturn && lineFeed) {
                      return "\r\n";
                  }
  
                  // found only carriage return, check next character as well
                  if (carriageReturn && !nextIteration) {
                      nextIteration = true;
                      continue;
                  }
  
                  if (lineFeed) { // we have a line-feed and no carriage return before
                      return "\n";
                  } else if (carriageReturn) { // only carriage return found before, seems to macOS 9 line ending
                      return "\r";
                  }
              }
          } catch (IOException _ex) {
              return SystemUtil.LINE_SEPARATOR;
          }
  
          return SystemUtil.LINE_SEPARATOR;
      }
docs: Tries to find the line termination character(s) of the given file.
  Only useful for files with text content!
  
  @param _file
  @return never null, will return system default line terminator on any error