是否在Java中定义了Newline常量,如C#中的Environment.Newline? [英] Is there a Newline constant defined in Java like Environment.Newline in C#?
本文介绍了是否在Java中定义了Newline常量,如C#中的Environment.Newline?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在C#中有静态属性 Environment.Newline 根据运行平台而改变。
In C# there is the static property Environment.Newline that changed depending on the running platform.
Java中有类似内容吗?
Is there anything similar in Java?
推荐答案
从Java 7开始(和Android API级别19):
System.lineSeparator()
对于旧版本的Java,请使用:
System.getProperty("line.separator");
参见 https://java.sun.com/docs/books/tutorial/essential/environment/sysprop.html 。
这篇关于是否在Java中定义了Newline常量,如C#中的Environment.Newline?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文