View Single Post
  #2 (permalink)  
Old 04-22-2008, 03:42 AM
rico16135 rico16135 is offline
Member
 
Join Date: Apr 2008
Posts: 28
rico16135 is on a distinguished road
Code:
// File (or directory) to be moved File file = new File("filename"); // Destination directory File dir = new File("directoryname"); // Move file to new directory boolean success = file.renameTo(new File(dir, file.getName())); if (!success) { // File was not successfully moved }

-------------------------------------------------------------
that should move them, here's how to find them
-------------------------------------------------------------



Code:
import java.io.File; public class DirectoryReader { public static void main(String[] args) { File folder = new File("c:/"); File[] listOfFiles = folder.listFiles(); for (int i = 0; i < listOfFiles.length; i++) { if (listOfFiles[i].isFile()) { System.out.println("File " + listOfFiles[i].getName()); } else if (listOfFiles[i].isDirectory()) { System.out.println("Directory " + listOfFiles[i].getName()); } } } }
Reply With Quote