Sponsors: Michael Fertik - Best JAVA Web hosting Company & 30% off


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-26-2007, 08:34 AM
Ada Ada is offline
Member
 
Join Date: May 2007
Posts: 8
Rep Power: 0
Ada is on a distinguished road
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?
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 05-26-2007, 01:17 PM
levent
Guest
 
Posts: n/a
Default
Hi Ada,

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

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
    }
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


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


Java Forums is supported by the best jsp hosting.

All times are GMT +2. The time now is 08:47 PM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org