How to find out which line separator BufferedReader#readLine() used to split the line?

后端 未结 9 1445
星月不相逢
星月不相逢 2020-12-11 01:47

I am reading a file via the BufferedReader

String filename = ...
br = new BufferedReader( new FileInputStream(filename));
while (true) {
   String s = br.re         


        
9条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-11 02:29

    The answer would be You can't find out what was the line ending.

    I am looking for what can cause line endings in the same funcion. After looking at the BufferedReader source code, I can saz that BufferedReader.readLine ends line on '\r' or '\n' and skips leftower '\r' or '\n'. Hardcoded, does not care about settings.

提交回复
热议问题