aspose file tools*
The moose likes Beginning Java and the fly likes Renaming a file in Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Renaming a file in Java" Watch "Renaming a file in Java" New topic
Author

Renaming a file in Java

Nair Anoop
Ranch Hand

Joined: May 09, 2001
Posts: 68
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
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
Cindy, thanks for your help. Wonder how I didn't think of it.
~Anoop
Val Dra
Ranch Hand

Joined: Jan 26, 2001
Posts: 439
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);
}
}


Val SCJP <BR>going for SCJD
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Renaming a file in Java
 
Similar Threads
conversion
about java decompiler
please help me out.. exam tomorrow
Hi, All SCJP Candidate help me
Failed to marshal exception problem