简体   繁体   English

如何从属性文件获取文件路径并将其作为参数传递给方法

[英]How get file path from property file and pass into the method as arguments

In Property file: 在属性文件中:

FolderPath =C:\\pre-configured/Import.csv FolderPath = C:\\ pre-configured / Import.csv

In Main class im passing this path as argument for a method load 在Main类中,我将此路径作为方法加载的参数传递

Properties pro = new Properties();
new CSV().load(con,"pro.FolderPath", "VALIDATION");

but it is giving error as: 但它给出错误为:

pro.getProperty(FolderPath) (The system cannot find the file specified.)

Please help in passing this path into the method as argument. 请帮助将此路径作为参数传递给方法。

You need to load a Properties file first: 您需要首先加载属性文件:

FileReader reader = new FileReader( "your properties file path" );

Properties prop2 = new Properties();
prop2.load( reader );
prop2.list( System.out );

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM