java .properties文件值中的换行符

编程入门 行业动态 更新时间:2024-10-08 08:28:18
本文介绍了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文件值中的换行符

本文发布于:2023-11-28 17:52:48,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1643383.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件   换行符   java   properties

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!