Using the List and RenameTo methods
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   ed_wrede
Posted On:   Monday, May 31, 2004 01:33 AM

Hi everyone.
You guys might have seen my other post about copying files from 1 directory to another in a java class.
Ive spent abit of time learning some java and using JBuilder and now ive gotta write this class.
My thinking is that i can use the List method to find out how many files are in a directory and then i can use the RenameTo method to change the path and thereby copy the file.
Ive been browsing around in the Java Docs but i cant figure out the correct code to use these 2 methods, can anyone offer me some help?
Thanks alot!

Re: Using the List and RenameTo methods

Posted By:   rahul_deshmukh  
Posted On:   Thursday, June 3, 2004 06:09 AM

See this code :

File file=new File("d:\file.txt");

File file1 = new File("d:\file1.txt");

Now to rename file1.txt to file.txt you will use following code :

file1.renameTo(file);
About | Sitemap | Contact