Marina
Marina

Reputation: 122

Resource file cannot be found

I'm new to Java. I use Eclipse IDE. I have such structure of packages :

Java src:
         -1)org.pdfbox;
         -2)org.pdfbox.util;
         -3)org.pdfbox.pdmodel.interactive.documentnavigation.outline
         - .....
         -4)org.pdfbox.util;
                         -4.1)ResourceLoader.java - loads data from .properties file ;
                         -4.2).....
                         -4.3).....
         -5)org.pdfbox.Resources;
                         -5.1)files to be downloaded (*.properties).

Package with Resources has gray icon, others packages have brown icons. ResourceLoader throws an exception "file cannot be found" when I try to load file from org.pdfbox.Resources. Is there way to include package with properties into project or something else? I have tried to set ab absolute or relative paths to my properties file. Would be very greatful for your help.

Upvotes: 1

Views: 555

Answers (1)

limc
limc

Reputation: 40168

If your properties file is called myfile.properties, then your code should look like this:-

ResourceBundle rb = ResourceBundle.getBundle("org.pdfbox.Resources.myfile");

// get the string value from key "myvar" from the properties file
String s = rb.getString("myvar"); 

Upvotes: 2

Related Questions