Wednesday, September 30, 2009

There is some code where I work that defines a constant with the value of System.getProperty("line.separator") and uses it for the line separator. This would be the right thing to do if the code were talking to the local system, but it was using it for internet protocols, which just as wrong as using the system default character encoding for internet protocols. I guess the person who wrote the code was blindly following some rule, meant apply to for coding local applications, that said System.getProperty("line.separator") should be used instead of "\n" (or "\r\n" or whatever) when writing portable code. For internet protocols, it should use whatever the protocol specifies, usually "\r\n", as the line separator, rather than the platform-specific line separator.

No comments:

Post a Comment