Creating a New File Using Java
A while back I wrote about creating a CFMX wrapper for java file reader, which I used to read files in from within <cfscript>. However I wondered how you’d go about creating a new file and by creating and java.io.File object and dumping I spotted a method called createNewFile(). Here is the snippet that creates the object and the new file:
[code]// create the file stream
filename = “/absolutePath/toYourFile”;
jFile = createobject(“java”, “java.io.File”);
jFile.init(filename);
// the file doesn’t exist so use the file stream to create it
jFile.createNewFile();[/code]
This also works on BlueDragon.