Is there any way to store resource file(.properties) in struts 1.x in UTF-8 format. Whenever i save the file it is saved in ISO-8859 format.
Also, can i create a text file in resources folder of struts directory which will act as properties file (so that the text file can be saved in UTF-8 format), and read that file in my application to show the static text of Greek, Russian or any language.
I have read the following and try to come up with the solution but it hasn't work :
https://stackoverflow.com/a/863854/3493471
Using this my code looks like this :
import java.util.Properties;
import java.io.*;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class PropertiesListener {
private static Log log = LogFactory.getLog(PropertiesListener.class);
protected static Properties readProperties(String name){
Properties prop = new Properties();
InputStream inputStream = null;
try {
//inputStream = new FileInputStream(name);
inputStream = EditMailboxAction.class.getResourceAsStream(name);
Reader reader = new InputStreamReader(inputStream, "UTF-8");
log.debug("Length :: "+reader.ready());
try {
prop.load(reader);
} catch(Exception ex){
log.debug("1111111111111111111111111");
ex.printStackTrace();
}finally {
reader.close();
}
}catch(FileNotFoundException ex){
log.debug("22222222222222222222");
ex.printStackTrace();
}catch(Exception ex){
ex.printStackTrace();
}
finally {
}
return prop;
}
}
I have called this above function to read the file using :
Properties properties = PropertiesListener.readProperties("myProperties.properties");
But it doesn't make it helpful.
As myProperties.properties isn't storing UTF-8 Charectors, I don't understand how
Reader reader = new InputStreamReader(inputStream, "UTF-8");
will help in reading UTF-8 charectors.