我有一个.ini文件,如下所示:
[Filepath]
Inbound=C:\Users\Bilbo\Desktop\Testing我想返回确切的字符串(C:\Users\Bilbo\Desktop\Testing),并且我有以下代码:
public static String ParseIniInbound (File iniFile) throws
InvalidFileFormatException, IOException {
String iniFileName = iniFile.toString();
Ini ini = new Ini(new File(iniFileName));
String InboundPath= ini.get("Filepath", "Inbound");
return InboundPath;
}但是,返回的是C:UsersBilboDesktopTesting
我尝试在.ini文件中的文件路径两边加上引号,将其作为字符串读取,但不起作用。我使用了双斜杠(C:\Users\Bilbo\Desktop\Testing),它返回(C:\Users\Bilbo\Desktop\Testing),但我希望能够只复制和粘贴文件路径,而不必手动输入双斜杠。有没有一种方法可以用ini4j或其他方法从.ini文件中读入字符串?谢谢
发布于 2019-03-12 20:15:18
嗯,我找不到任何关于这方面的东西,除了你的帖子,所以这是我的解决方案,但如果这是预期的方式,它真的很愚蠢。
ini.put("Default_Values", "dWorkflowStart", "C:\\" + "\\User\\" + "\\kh\\" + "\\Desktop\\"
+ "\\workstuff\\" + "\\samples\\" + "\\test_in");这会使[Default_Values] dWorkflowStart = C:\\Users\\kh\\Desktop\\workstuff\\samples\\test_in
https://stackoverflow.com/questions/51315207
复制相似问题