Different Operating Systems handle newlines in a different way.Hereis a short list of the most common ones.
DOS and Windows
They expect a newline to be the combination of two characters,namely "\r\n"
Unix( Linux aswell)
Unix uses a single "\n" to indicate a new line.
Macs
Macs use a single "\r".
一向知道不同环境下的文件在兼容性上会有问题。这次在项目测试中,基于Unix环境测试没有问题的程序,在windows下无法正常运行,原因在于换行的时候使用的writeline函数,在不同的平台下使用的是不同的换行符,而在使用Camel的route的时候,使用了"\n"作为分隔符来生成sql,最终导致了数字串中混杂了"\r"成了字符串,最后插入数据库失败。
作为一个肉眼无法发现的问题,在写程序的当时未必会想到要跑在不同的环境下,结果出了问题的时候很难挑出bug.
DOS and Windows
They expect a newline to be the combination of two characters,namely "\r\n"
Unix( Linux aswell)
Unix uses a single "\n" to indicate a new line.
Macs
Macs use a single "\r".
一向知道不同环境下的文件在兼容性上会有问题。这次在项目测试中,基于Unix环境测试没有问题的程序,在windows下无法正常运行,原因在于换行的时候使用的writeline函数,在不同的平台下使用的是不同的换行符,而在使用Camel的route的时候,使用了"\n"作为分隔符来生成sql,最终导致了数字串中混杂了"\r"成了字符串,最后插入数据库失败。
作为一个肉眼无法发现的问题,在写程序的当时未必会想到要跑在不同的环境下,结果出了问题的时候很难挑出bug.