Can we specify directory path with the property file while using ResourceBundle class in Java?

R. Rahul :

I want to place my properties files in some folder, but I am not able to read them because we can specify only the bundle name in static getBundle() method on ResourceBundle object.

Suppose bundle is: myFile.properties
Current path is: src
I want to keep my properties file in: src/temp

So when I am using:

ResourceBundle.getBundle("temp/myfile", currentLocale);

it is throwing an exception "can't find bundle". I want some way to specify the path. Please suggest me some way to do this.

Thank you

Abhinav Sarkar :

Use this:

ResourceBundle.getBundle("temp.myfile", currentLocale);

The baseName supplied in the ResourceBundle.getBundle call is supposed to be a fully qualified class name. So it has to be written separated with dots. Also note that this makes temp a package in your java code (which I don't think is a good idea). It is better to put the properties file in a proper package like com.xyz.abc. Then you can access it using

ResourceBundle.getBundle("com.xyz.abc.myfile", currentLocale);

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

How do I specify values in a properties file so they can be retrieved using ResourceBundle#getStringArray?

From Java

Error while using the load class from Java to import property file

From Dev

Resolve environment variables of property file Java ResourceBundle

From Dev

Can I specify a "base package path" for a directory in Java?

From

Can I specify a path in an attribute to map a property in my class to a child property in my JSON?

From Mysql

How can we add file in project directory using javascript onclick?

From Dev

How to specify path in file in the same directory?

From Dev

How to specify directory path in .bat file?

From Dev

Specify directory for Serilog rolling file path

From Dev

Can we pass a Url path and a file name to FileOutputStream in java

From Dev

Java: No Such File Or Directory (Using Scanner Class)

From Dev

Can we explicitly specify what feature to be extracted from an image while using CNN

From Dev

specify directory or path using slash or dot slash

From Dev

How we can specify mapping files using <mapping file=""/> in hibernate configuration file

From Dev

SonarQube Vulnerability while using File class in Java

From Dev

Specify ResourceBundle within FXML file in JavaFX

From Dev

'Errno 2 no such file or directory' Problem with white space in directory path while using subprocessing module Popen command

From Dev

Error while loading shared libraries: No such file or directory even after using LD_LIBRARY_PATH and changing $PATH

From Java

Java - How to create a file in a directory using relative Path

From Java

Copy a directory while preserving symlinks using Java File/IO APIs

From Dev

How to specify a file path using '~' in Ruby?

From Dev

Django: IOError [Errno 2] No such file or directory while Reading JSON file path using python

From Dev

Can we define all the Named Queries at one place like some property file instead of writing in the entity class

From Dev

Specify a file path that begins with the top-most directory

From Dev

how to specify drupal mail save file module's directory path?

From Dev

How to specify path to read a .txt file in assets directory

From Java

Using relative directory path in Java

From Dev

Executing a Java class file using the command line, but from the "wrong" directory

From Dev

Java cannot find the class file, while javap can

Related Related

  1. 1

    How do I specify values in a properties file so they can be retrieved using ResourceBundle#getStringArray?

  2. 2

    Error while using the load class from Java to import property file

  3. 3

    Resolve environment variables of property file Java ResourceBundle

  4. 4

    Can I specify a "base package path" for a directory in Java?

  5. 5

    Can I specify a path in an attribute to map a property in my class to a child property in my JSON?

  6. 6

    How can we add file in project directory using javascript onclick?

  7. 7

    How to specify path in file in the same directory?

  8. 8

    How to specify directory path in .bat file?

  9. 9

    Specify directory for Serilog rolling file path

  10. 10

    Can we pass a Url path and a file name to FileOutputStream in java

  11. 11

    Java: No Such File Or Directory (Using Scanner Class)

  12. 12

    Can we explicitly specify what feature to be extracted from an image while using CNN

  13. 13

    specify directory or path using slash or dot slash

  14. 14

    How we can specify mapping files using <mapping file=""/> in hibernate configuration file

  15. 15

    SonarQube Vulnerability while using File class in Java

  16. 16

    Specify ResourceBundle within FXML file in JavaFX

  17. 17

    'Errno 2 no such file or directory' Problem with white space in directory path while using subprocessing module Popen command

  18. 18

    Error while loading shared libraries: No such file or directory even after using LD_LIBRARY_PATH and changing $PATH

  19. 19

    Java - How to create a file in a directory using relative Path

  20. 20

    Copy a directory while preserving symlinks using Java File/IO APIs

  21. 21

    How to specify a file path using '~' in Ruby?

  22. 22

    Django: IOError [Errno 2] No such file or directory while Reading JSON file path using python

  23. 23

    Can we define all the Named Queries at one place like some property file instead of writing in the entity class

  24. 24

    Specify a file path that begins with the top-most directory

  25. 25

    how to specify drupal mail save file module's directory path?

  26. 26

    How to specify path to read a .txt file in assets directory

  27. 27

    Using relative directory path in Java

  28. 28

    Executing a Java class file using the command line, but from the "wrong" directory

  29. 29

    Java cannot find the class file, while javap can

HotTag

Archive