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

后端 未结 9 1429
星月不相逢
星月不相逢 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:54

    If you happen to be reading this file into a Swing text component then you can just use the JTextComponent.read(...) method to load the file into the Document. Then you can use:

    textComponent.getDocument().getProperty( DefaultEditorKit.EndOfLineStringProperty );
    

    to get actual EOL string that was used in the file.

提交回复
热议问题