java .properties文件值中的换行符 [英] newline char in the java .properties file value

查看:458
本文介绍了java .properties文件值中的换行符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是否真的需要使用原始的unicode char转义来将换行符嵌入我的.properties文件中?

do I really need to resort ot raw unicode char escapes to embed newlines into my .properties file?

文档中这篇冗长的讨论很酷但我不知道这一点。现在尝试再次扫描这个批量,但也许有人知道?

This lengthy discussion in documentation is cool but I somehow miss this point. Now trying to scan this bulk once again, but maybe someone knows?

谢谢,
Anton

Thanks, Anton

更新


某些特殊字符,可以表示键
和使用转义序列的元素类似于使用
表示字符和字符串文字的元素

certain special characters, can be represented in keys and elements using escape sequences similar to those used for character and string literals

我不是那样的确定那些'某些特殊字符'可能是什么。 1.4 javadocs的直接链接没有导致规范的正确部分。但在查找正确的段落之后对我来说很清楚。

I was not that sure what those 'certain special characters' might be. The direct link from 1.4 javadocs did not lead to the proper section of the spec. But after looking up the proper paragraph this got quite clear for me.

推荐答案


我真的需要使用原始的unicode char转义来将换行符嵌入我的.properties文件?

do I really need to resort ot raw unicode char escapes to embed newlines into my .properties file?

不。我希望 \ r \ n \\\\ n 工作正常。您声称链接文档遗漏了这一点,但它似乎与我非常相关:

Nope. I'd expect \r or \n or \r\n to work just fine. You claim that the linked documentation misses the point, but it seems pretty relevant to me:


不在Latin1中的字符,以及某些特殊字符,可以使用类似于用于字符和字符串文字的转义序列在键和元素中表示(参见Java语言规范的§3.3和§3.10.6)。

Characters not in Latin1, and certain special characters, can be represented in keys and elements using escape sequences similar to those used for character and string literals (see §3.3 and §3.10.6 of the Java Language Specification).

第3.10.6节是你想要的,对吗?

这篇关于java .properties文件值中的换行符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆