Hi all, Is there any method by which I can RENAME a file using Java (not invoking a MSDOS command) ? Please let me know. Thanks in advance, Anoop
Cindy Glass
"The Hood"
Sheriff
Joined: Sep 29, 2000
Posts: 8521
posted
0
You read it in. You write it out to a new name. You delete the old one.
"JavaRanch, where the deer and the Certified play" - David O'Meara
Nair Anoop
Ranch Hand
Joined: May 09, 2001
Posts: 68
posted
0
Cindy, thanks for your help. Wonder how I didn't think of it. ~Anoop
Val Dra
Ranch Hand
Joined: Jan 26, 2001
Posts: 439
posted
0
you might be doing extra work then needed all you need to do is call method renameTo on File object. public class Test { public static void main(String[] args) { File f = new File("c:/dude.txt"); File newObj = new File("c:/d.txt"); f.renameTo(newObj); } }