首页 > 编程知识 正文

成都不让外省人员返回吗,拟返回时间是什么意思

时间:2023-05-04 12:36:25 阅读:216445 作者:1204

What should I see when I use the following?

I get the following back:

Is it empty? invisible? shouldn there be something like r or n?

I use windows 7, eclipse and jdk 1.8.

解决方案

As you expect, the line separator contains special characters such as 'r' or 'n' that denote the end of a line. However, although they would be written in Java source code with those backslash escape sequences, they do not appear that way when printed. The purpose of a line separator is to separate lines, so, for example, the output of

is

Hello

World

rather than, say

HellonWorld

You can even see this in the output of your code: the output of

had an extra blank line before the output of the next statement, because there was a line separator from System.getProperty("line.separator") and another from the use of println.

If you really want to see what the escaped versions of the line separators look like, you can use escapeJava from Apache Commons. For example:

import org.apache.commons.lang3.StringEscapeUtils;

public class LineSeparators {

public static void main(String明亮的中心 args) {

String ls1 = StringEscapeUtils.escapeJava(System.getProperty("line.separator"));

String ls2 = StringEscapeUtils.escapeJava(System.lineSeparator());

}

}

On my system, this outputs

LineSeparator1: n

LineSeparator2: n

Note that I had to run it in the same folder as the .jar file from the Apache download, compiling and running with these commands

javac -cp commons-lang3-3.4.jar LineSeparators.java

java -cp commons-lang3-3.4.jar:. 要减肥的冷风/p>

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。