Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

File not found error occur when read property file in java

i create the property file under package of resources/common/configure/

then i create the code

    Properties prop = new Properties();

    try {
           //load a properties file
        prop.load(new FileInputStream("resources/common/configure/commonData.properties"));

           //get the property value and print it out
            System.out.println(prop.getProperty("id"));


    } catch (IOException ex) {
        ex.printStackTrace();
    }

but i got the following error

java.io.FileNotFoundException: (The system cannot find the path specified)

please let me know how can i get this property file.

like image 570
AKZap Avatar asked Feb 21 '23 00:02

AKZap


1 Answers

Try with

prop.load(getClass().getResourceAsStream("resources/common/configure/commonData.properties"));
like image 192
jmj Avatar answered Feb 26 '23 12:02

jmj