Actually In my application I have mail sending functionality.. but the text which i am sending is in Arabic..
problem that I am facing here is it is giving me question mark (???)instead of arabic text..
Here I pasted all my codes for your reference
Step 1: Loading velocity properties:
VelocityContext context = new VelocityContext();
for (Map.Entry<
String, Object> content : messageContent.entrySet())
{
context.put(content.getKey(), content.getValue());
}
Note: here my content.getValue() is in arabic as I mentioned earlier
Step 2:Loading velocity Properties
InputStream velocityStream =
MessageContent.class
.getResourceAsStream(MessageConstants.PROPERTY_FILE_VELOCITY);
Properties velocityProperties = new Properties();
velocityProperties.load(velocityStream);
MessageConstants.PROPERTY_FILE_VELOCITY loading from below three lines
runtime.log.logsystem.class=org.apache.velocity.runtime.log.NullLogSystem
input.encode="UTF-8"
output.encode="UTF-8" .
Step 3:Getting vm template content
String contentTemplate = getContent(contentTypeName);
contentTypeName is the file name of my vm template like abc.vm
Step 4:
Initializing velocity properties
Velocity.init(velocityProperties);
Step 5 :
evaluating velocity
ie, loading my content value to the vm template in this case abc.vm file
Velocity.evaluate(velocityContext, contentWriter, "LOG", contentTemplate);
I have pasted complete method here for your reference:
public static String getContentData(String contentTypeName, VelocityContext velocityContext)
{
// Load the velocity.properties.
// Load the template.
StringWriter contentWriter = new StringWriter();
InputStream velocityStream =
MessageContent.class
.getResourceAsStream("/velocity.properties");
Properties velocityProperties = new Properties();
velocityProperties.load(velocityStream);
String contentTemplate = getContent(contentTypeName);
if (StringUtils.isEmpty(contentTemplate))
{
log.error("Template content not retrieved.");
}
Velocity.init(velocityProperties);
Velocity.evaluate(velocityContext, contentWriter, "LOG", contentTemplate);
return contentWriter.getBuffer().toString();
GUIDE ME HOW TO RESOLVE THIS ISSUE AND DISPLAY PROPER ARABIC TEXT IN MY EMAIL..
NOTE:- IF POSSIBLE I NEED TO CONVERT THIS ARABIC TO ENGLISH AND DISPLAY IT IN EMAIL
AND ONE MORE THING THIS TEXT WILL BE DYNAMIC EVERY TIME.......
THANKS IN ADVANCE !!!