velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Will Glass-Husain <wglasshus...@gmail.com>
Subject Re: File exists
Date Thu, 09 Apr 2015 13:06:47 GMT
You can't instantiate objects in Velocity for an arbitrary class.
 remember, Velocity is intended to be a templating, not a scripting
language.

Create a new class FileHelper which has a method "fileExists(string)".
Pass it into the context in your java code as a reference "fileHelper".
Then in your template call do

$fileHelper.fileExists("/mnt/etc/etc/etc/")

WILL

On Thu, Apr 9, 2015 at 5:58 AM, <phiroc@free.fr> wrote:

> Hello,
>
> does anyone know how to check if a file exists in Velocity?
>
> I have tried:
>
> #set ($exists = new
> File().exists("/mnt/xxxparnex01_pdf/PDF/IHT/${pdf_year_mon_v}/${pdf_day_v}/${pdf_name_page_number}_${pdf_name_page_type}_VIG.jpg")
> )
>
> to no avail.
>
> Cheers,
>
> Philippe
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message