Results 1 to 2 of 2
  1. #1
    Ada is offline Member
    Join Date
    May 2007
    Rep Power

    Default How to Move a File to Another Directory

    I have a similar question. How can i move a file to another directory with Java?

  2. #2
    levent Guest


    Hi Ada,

    You can move your file as in the following code segment:

    Java 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

Similar Threads

  1. Is there a way to read a file directory
    By willemjav in forum Java Applets
    Replies: 3
    Last Post: 09-05-2011, 01:01 AM
  2. intimating file(s) have reached/copied in directory
    By ashu261 in forum Threads and Synchronization
    Replies: 1
    Last Post: 04-23-2008, 06:24 PM
  3. How to get Current Directory through File
    By Java Tip in forum
    Replies: 0
    Last Post: 04-05-2008, 10:14 AM
  4. signaling file(s) have reached in directory
    By ashu261 in forum Advanced Java
    Replies: 0
    Last Post: 02-04-2008, 07:45 AM
  5. File drop zones don't move with window in Firefox
    By jazgold in forum Java Applets
    Replies: 2
    Last Post: 01-02-2008, 10:25 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts