I have met the following text in the Java Specification

Lines are terminated by the ASCII characters CR, or LF, or CR LF. The two characters CR immediately followed by LF are counted as one line terminator, not two.

It is unclear whether the bolded text means the following combination of the line termination symbols CR LF CR LF or just CR CR LF.

  • 3
    It means CR LF. – We oath to creation Mar 11 at 18:58
  • 2
    It simply means CR LF. Two characters (bytes) with ASCII value 13 and 10, which together make a single line termination. – Weather Vane Mar 11 at 18:58
  • 1
    No, because that is not what is meant. AFAIK, CR LF CR LF would be counted as two line terminators. – We oath to creation Mar 11 at 19:09
  • 3
    Let me make it clear using brackets: "The two characters (CR immediately followed by LF) are counted as one line terminator, not two." – We oath to creation Mar 11 at 19:12
  • 2
    It's not very well written. – Weather Vane Mar 11 at 19:15

Perhaps the following would have been less confusing in the specification ...

The following ASCII character sequences each act as one line terminator:

  • CR
  • LF
  • CR LF

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.