从ini文件读取路径,反斜杠转义字符消失? [英] Reading path from ini file, backslash escape character disappearing?

查看:1496
本文介绍了从ini文件读取路径,反斜杠转义字符消失?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从ini文件中读取绝对路径名,并将路径名作为String值存储在我的程序中。但是,当我这样做时,存储的价值似乎正在失去反斜杠,所以路径只是出来一个大混乱的混乱?例如,ini文件将具有键值:

  key = C:\folder\folder2\filename .extension 

,存储的值作为 C:folderfolder2filename



有没有人知道如何在之前转义密钥



我们还假设,更改ini文件的值不是一种替代,因为它不是我创建的文件。

解决方案

尝试将Ini4j中的escape属性设置为false。




  • a href =http://ini4j.sourceforge.net/apidocs/org/ini4j/Config.html#setEscape%28boolean%29 =nofollow> http://ini4j.sourceforge.net/apidocs/org/ ini4j / Config.html#setEscape%28boolean%29



您可以尝试:

  Config.getGlobal()。setEscape(false); 


I'm reading in an absolute pathname from an ini file and storing the pathname as a String value in my program. However, when I do this, the value that gets stored somehow seems to be losing the backslash so that the path just comes out one big jumbled mess? For example, the ini file would have key, value of:

key=C:\folder\folder2\filename.extension

and the value that gets stored is coming out as C:folderfolder2filename.extension.

Would anyone know how to escape the keys before it gets read in?

Let's also assume that changing the values of the ini file is not an alternative because it's not a file that I create.

解决方案

Try setting the escape property to false in Ini4j.

You can try:

Config.getGlobal().setEscape(false);

这篇关于从ini文件读取路径,反斜杠转义字符消失?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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