I have a text file with name data.txt which includes Customer's details. I need to send a Msg to each Customer using apache velocity. My file look like this
enter code here
First_Name, City, ...
Rakesh, Hyderabad,...
Jack, berlin,...
...., ...., ...
like this 10000 records are their.. i don't know apache velocity very much.. i am unable to load my file in velocity. my java file
public static void main(String[] args) throws Exception {
Velocity.init();
Template t = Velocity.getTemplate("./src/VMDemo.vm");
VelocityContext ctx = new VelocityContext();
Writer writer = new StringWriter();
t.merge(ctx, writer);
System.out.println(writer);
VM file
#if ($City == "Hyderabad")
Hi $first_Name welcome to Hyderabad.
#elseif ($City == "Berling")
Hi $First_Name welcome to Berlin
#elseif ($City == "Mumbai")
Hi $First_Name welcome to Mumbai
#else
Please contact Us
#end
enter code here
the output should be like this..
Hi Rakesh welcome to Hyderabad.
Someone please suggest me how to load data and use in velocity. If Person belongs to some city then the name should be taken dynamically from a file. Please Someone help me out with this.. just help me including my file in velocity.