Hello,
New to forum and also C Sharp. I want to load 'filename.properties' based on users language and read its keys like
if I say Console.WriteLine("hello "+ properties.getKey(hello.user)) it should print
hello english_user1 for english user.
hello french_user1 for french user.
my property file will look something as follows.
filename_english.properties: (for english user)
hello.user = english_user1
hello.pass= english_pass1
filename_french.properties: (for french user)
hello.user = french_user1
hello.pass = french_pass1
In java I can do above as follows:
public void loadMyPropertyFile() {
public Properties props = new Properties();
String userLanguage = "fr";
try {
InputStream is = this.getClass().getClassLoader().getResourceAsStream("resourcebundle/filename"+userLanguage+".properties");
if (is == null) {
throw new RuntimeException("Failed to load properties file: " + "filename"+userLanguage+".properties");
}
props.load(is);
is.close();
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException("Failed to load properties file: " + "resourcebundle/filename"+userLanguage+".properties");
}
}
I didn't fount Properties class companio and "this.getClass().getClassLoader().getResourceAsStream" companion of java in c#.
I am stuck due to this and needs expert advice. Much thanks in advance.
Thanks and Regards,
Rohit pol..