• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 150
  • Last Modified:

Need file of whitespaces to be considered empty

I want the code below to ignore files that are empty.  Empty in this case means it has no characters or if it has characters then it should be whitespace characters only.  The code below is only calling it 'empty' in the former case and not the latter and this results in processing that I do not want.

Could you provide code to replace this.

<cfset size = createObject("java","java.io.File").init(variables.FileNameLocation).length() />
<cfif size gt 0>.....Processing Here......</>

Open in new window

1 Solution
you can easily do it using <cffile>:

<cffile action="read" file="#variables.FileNameLocation#" variable="myfile">
<cfset size = len(rereplace(myfile, '\s', '', 'all'))>

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now