General discussion
-
Topic
-
moving files in java
LockedI want to move files from one folder to another in Java. I used the renameTo method in the File class but that doesnt helps me…
Am posting my code here, can some one look at it and tell me whats wring in it and also is there an efficient way to move files in Java across folders…public boolean moveFiles(String source, String destination)
{
//This method moves the files from one directory to another
File sourceDir = new File(source.trim());
File destinationDir = new File(destination.trim());boolean created = true;
if(!destinationDir.exists())
{
//Create that directorycreated = destinationDir.mkdir();
System.out.println(“The directory created ” + created);//do the moving of files here
File [] tmp = sourceDir.listFiles();
for(int i =0;i