Java 如何从属性文件中获取文件路径并作为参数传递到方法中

Java 如何从属性文件中获取文件路径并作为参数传递到方法中,java,Java,在属性文件中: 文件夹路径=C:\pre-configured/Import.csv 在Main类中,我将此路径作为方法加载的参数传递 Properties pro = new Properties(); new CSV().load(con,"pro.FolderPath", "VALIDATION"); 但它给出的错误是: pro.getProperty(FolderPath) (The system cannot find the file specified.) 请帮助将此路径作为参

在属性文件中:

文件夹路径=C:\pre-configured/Import.csv

在Main类中,我将此路径作为方法加载的参数传递

Properties pro = new Properties();
new CSV().load(con,"pro.FolderPath", "VALIDATION");
但它给出的错误是:

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

请帮助将此路径作为参数传递到方法中。

您需要先加载属性文件:

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

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

您需要首先加载属性文件:

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

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

向我们展示你的加载方法public void load(连接连接,字符串csvFile,字符串tableName)方法体呢?实际上发布完整的代码,因为它不是很清楚。我的问题是,如何将属性文件中定义的FolderPath传递到这个方法new CSV().load(con,“pro.FolderPath”,“VALIDATION”);当我手动传递路径时,它会工作。但我想从属性文件加载路径。如何做到这一点?向我们展示您的load methodpublic void load(连接、字符串csvFile、字符串tableName)方法体如何?实际上发布完整的代码,因为它不是很清楚。我的问题是,如何将属性文件中定义的FolderPath传递到此方法new CSV().load(con,“pro.FolderPath”、“VALIDATION”);当我手动传递路径时,它会工作。但我想从属性文件加载路径。怎么做?