[Top] [All Lists]

Re: convert text to list

Subject: Re: convert text to list
From: "Stressed_Simon"
Date: Thu, 16 Aug 2007 21:59:05 +0000 UTC
Newsgroups: macromedia.coldfusion.cfml_general_discussion
createObject() is used to create instances of classes. Now these can be 
ColdFusion components, Java classes, CORBA objects and web services. In the 
example I showed you I am creating an instance of the java.lang.String class 
this is a native class of Java. In Java all Strings are actually objects with 
methods. So the if I had just done <cfset bar = createObject("java", 
"java.lang.String").init(foo)> that calls the constructor of the String class 
and creates a String object with the content of foo. But in this instance I 
suggested <cfset bar = createObject("java", 
"java.lang.String").init(foo).split("\n")> now this creates the object and 
calls the split() method. This method takes an Regex argument and then returns 
an array that is split on the regex you passed "\n" is Regex for a new line so 
it will create an array containing each row of your text file. Looping through 
arrays in ColdFusion MX onwards are majorly faster than lists.

 I hope that clears it up.

<Prev in Thread] Current Thread [Next in Thread>