Yeah,
That will create a file, rename it and delete it.
File read and write operations are somewhat more involved.
You'll definitely be better off wrapping up the file operations in a
cffunction block, but if you really do want to find out some more about it,
here's some java code to read the contents of a file:
public String readFile(File input) {
BufferedReader in = null;
try {
StringBuffer buffer = new StringBuffer();
in = new BufferedReader(new FileReader(input));
String str;
while ((str = in.readLine()) != null) {
buffer.append(str + System.getProperty("line.separator"));
}
in.close();
return buffer.toString();
} catch (FileNotFoundException e) {
System.out.println("Error! The file " + input + " could not be found.");
} catch (IOException e) {
System.out.println("Error! An IO Exception occurred.");
System.out.println(e.getMessage());
} finally {
try {
in.close();
} catch (IOException e) {
e.printStackTrace();
} catch (NullPointerException e) {
// something wasn't initialized, just ignore this error
}
}
return null;
}
Converting that lot to CF should keep you busy for a while ;-)
Spike
On 10/28/05, Nathan Strutz <[EMAIL PROTECTED]> wrote:
>
> If you want to check out the java way, you can browse through
> java.IO.*, which has a lot of IO general classes including working
> with the file system, and when in doubt, google it. Generally
> speaking, you do something sort of like this:
>
> myFile = createObject("java","java.IO.File").init("c:\myfile.txt");
> myFile.createNewFile();
> myFile.renameTo(createObject("java","java.IO.File
> ").init("c:\myfile2.txt"));
> myFile.delete();
>
> that's totally untested code, btw.
>
> Here's the javadoc link:
> http://java.sun.com/j2se/1.5.0/docs/api/java/io/File.html
>
> -nathan strutz
> http://www.dopefly.com/
>
> On 10/28/05, Paul <[EMAIL PROTECTED]> wrote:
> > I had the same thought, but was curious to learn a little more about how
> > Java works. But I did find the wrapper functions already written on
> > cflib.org <http://cflib.org> so maybe I'll just do that...
> >
> > -----Original Message-----
> > From: Simeon Bateman [mailto:[EMAIL PROTECTED]
> > Sent: Friday, October 28, 2005 1:39 PM
> > To: CF-Talk
> > Subject: Re: java equivalent of cffile
> >
> > The stupid simple answer I came up with in seeing your questions, was
> why
> > not just write a couple cffunctions to wrap cffile so you can access it
> from
> > script?
> >
> > I am probably missing something, but thats where I would look first.
> >
> > simeon
> >
> >
> > On 10/28/05, Paul <[EMAIL PROTECTED]> wrote:
> > >
> > > I know this has been covered but I don't know what phrase to search
> for
> > > exactly so here we are.
> > >
> > >
> > >
> > > How can I do CFFILE-like actions (create, overwrite, delete) within
> > > cfscript? I'm sure I can use the built-in Java functionality but I
> don't
> > > know what that is.
> > >
> > >
> > >
> > > TIA
> > >
> > >
> > >
> > > Paul
> > >
> > >
> > >
> > >
> >
> >
> >
> >
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking
application. Start tracking and documenting hours spent on a project or with a
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:222618
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54