code to move file from one location to another location

HI frnds,Could any body how i can move a file from on eloaction to another?thanks
[102 byte] By [System_analysta] at [2007-11-26 13:15:45]
# 1
1. Create a new file in ur destination folder2. Read the contents in source file and copy it to destination file3. Delete the source fileCheers
astelaveestaa at 2007-7-7 17:36:55 > top of Java-index,Java Essentials,New To Java...
# 2

BufferedReader br = new BufferedReader(new FileReader("C:\\SourceFolder\\data.txt"));

BufferedWriter bw = new BufferedWriter(new FileWriter("C:\\DestinationFolder\\data.txt"));

String str = null;

// Copy

while ((str = br.readLine()) != null) {

bw.write(str);

bw.newLine();

}

br.close();

bw.close();

//Delete

File f = new File("C:\\SourceFolder\\data.txt");

f.delete();

System.out.println("Moved Successfully!");

Cheers

astelaveestaa at 2007-7-7 17:36:55 > top of Java-index,Java Essentials,New To Java...
# 3
There is great feature called "Search Engine" :) http://www.java2s.com/Code/Java/File-Input-Output/CopyfilesusingJavaIOAPI.htm
Michael.Nazarov@sun.coma at 2007-7-7 17:36:55 > top of Java-index,Java Essentials,New To Java...
# 4
Ahh, you asked about moving not copying. I'm confused by answer from astelaveesta :)Well, there is another great feature called "File.renameTo()"
Michael.Nazarov@sun.coma at 2007-7-7 17:36:55 > top of Java-index,Java Essentials,New To Java...
# 5

Michael, Thanks for that info

File sourceFile = new File("C:\\SourceFolder\\data.txt");

File destinFile = new File("C:\\DestinFolder\\data.txt");

sourceFile.renameTo(destinFile);

Cheers

astelaveestaa at 2007-7-7 17:36:55 > top of Java-index,Java Essentials,New To Java...