尝试在属性上调用load方法时找不到符号错误

时间:2019-07-09 11:26:09

标签: java properties io

今天偶然发现一个奇怪的错误,我认为这与java无法正确读取其库有关或具有某种性质?

基本上,创建属性文件解析器时,无法加载属性(这是代码错误,不是我格式化属性文件之类的东西)。

这是我的代码:

package site.giacomo;

import java.io.*;
import java.util.*;

public class Properties {

    public void generateProperties() {
        // Creating the properties object.
        Properties properties = new Properties();
        // This is the location of the properties file. It should be in the "root" directory.
        try {
            FileInputStream ip = new FileInputStream("config.properties");
            // We will now load the properties in.
            properties.load(ip);
        } catch (FileNotFoundException e) {
            System.out.println("Properties failed on startup! Please check config.properties and ensure it is in the correct location!");
            e.printStackTrace();
        }

    }

}

我期望它能正常工作,但最终会出现此错误: 错误:找不到符号属性。load(ip);

0 个答案:

没有答案