This week's book giveaway is in the Reactive Progamming forum.
We're giving away four copies of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams and have Adam Davis on-line!
See this thread for details.
Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

Velocity Template text showing as a ?? mark if the text is Arabic

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 !!!
 
You'll never get away with this you overconfident blob! The most you will ever get is this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!