Created
February 8, 2013 15:19
-
-
Save ryanguill/4739645 to your computer and use it in GitHub Desktop.
coldfusion strings are already java strings underneath, and you can call the java String class methods on a CF string.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfscript> | |
// Converts a ColdFusion string in a java byte array | |
function createByteArray(string){ | |
var objString = createObject("Java", "java.lang.String").init(JavaCast("string", string)); | |
return objString.getBytes(); | |
} | |
</cfscript> | |
<cfset variables.myCFString = "Sally sells sea shells by the sea shore" /> | |
<cfdump var="#createByteArray(variables.myCFString)#" /> | |
<!--- cf strings are Java Strings ---> | |
<cfdump var="#variables.myCFString.getBytes()#" /> | |
<!--- you can call all of the Java String class's methods on a cf string ---> | |
<cfdump var="#variables.myCFString.split(" ")#" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment