Results 1 to 2 of 2
Thread: Moving file to another folder
- 03-03-2010, 06:24 AM #1
Member
- Join Date
- Mar 2010
- Posts
- 2
- Rep Power
- 0
Moving file to another folder
Hi forum,
I am a newbie to java. I'm stuck with this problem. I would like to move list of files from one folder to another folder. Can anyone give me a head start...Below is my code but this only moves a single file. How can i move multiple files?? Interate??Array??
If you know a tutorial about this, please provide the hyperlink.
ThanksJava Code:public static void moveFile() { try { // File (or Directory) to be moved File cFile = new File("C:/FolderA/[B]file.txt[/B]"); // Destination directory File dir = new File("C:/FolderB"); // Move file to a new directory boolean success = cFile.renameTo(new File(dir, cFile.getName())); System.out.println("Success::"+cFile.renameTo(new File(dir, cFile.getName()))); if (success) { System.out.println("File was successfully moved.\n"); } else { System.out.println("File was not successfully moved.\n"); } } catch (Exception ex) { System.out.println(ex); } }
Aiden
- 03-03-2010, 07:47 AM #2
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
Similar Threads
-
moving a file
By swati.jyoti in forum New To JavaReplies: 8Last Post: 11-23-2009, 08:44 AM -
need to get the file name from folder
By naveen.dpt2007 in forum New To JavaReplies: 2Last Post: 09-04-2009, 06:57 PM -
Copy a file to a folder.
By leric in forum New To JavaReplies: 7Last Post: 07-29-2009, 05:11 AM -
[SOLVED] File is Not Moving
By jazz2k8 in forum New To JavaReplies: 7Last Post: 07-07-2008, 10:58 AM -
moving a file
By Java Tip in forum Java TipReplies: 0Last Post: 11-10-2007, 07:52 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks