Location of VM files in velocity-1.7

Source: Internet
Author: User

VM file storage in velocity-1.7

Demo:

 Public   Class  App_example1 {  Public  App_example1 () {string propfile = "Velocity. properties" ; String vmfile = "App_example1.vm" ; Velocity. INIT (propfile); velocitycontext Context = New Velocitycontext (); context. Put ( "Games" , Getgamesinfo (); Template = Null  ; Template = Velocity. gettemplate (vmfile); bufferedwriter BW = New Bufferedwriter ( New  Outputstreamwriter (system. Out); template. Merge (context, BW );  Try  {BW. Flush (); BW. Close ();}  Catch (Ioexception e) {e. printstacktrace ();}}  Private List <string> Getgamesinfo () {list <String> List = New Arraylist <string> (); List. Add ( "War3" ); List. Add ( "Red alarm" ); List. Add ( "CS" ); List. Add ( "QQ Games" );  Return  List ;} Public   Static   Void  Main (string [] ARGs) {app_example1 app = New  App_example1 ();}} 


Analysis of VM file storage location:

The fileresourceloader. getresourcestream (string) method of velocity only searches for VM files in the root directory of the project. The parameter of this method is the VM file name.

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.