CRLF转换成java字符串 [英] CRLF into java string
本文介绍了CRLF转换成java字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在Java中编写了一个字符串,在这里我插入了一个LF(换行符),如下所示:
I've coded a string in Java where I inserted a LF (linefeed) at the end like this:
String str = "......\n";
现在我需要换行符由回程和CRLF 换行。在十六进制中, 0D 0A
而不是 0A
。有没有办法将其插入我的字符串?
Now I need to need newline made of a Carriage Return and a Line Feed, a CRLF. In hex that is 0D 0A
instead of 0A
. Is there a way to insert this into my string?
推荐答案
使用 \\\\ n
:
String str = "......\r\n";
来自 JLS :
\n /* \u000a: linefeed LF */
\r /* \u000d: carriage return CR */
这篇关于CRLF转换成java字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文