The Artima Developer Community
Sponsored Link

Java Answers Forum
Moving a file to other directories

1 reply on 1 page. Most recent reply: Jun 20, 2002 3:44 PM by Charles Bell

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
David

Posts: 1
Nickname: david
Registered: Jun, 2002

Moving a file to other directories Posted: Jun 20, 2002 7:27 AM
Reply to this message Reply
Advertisement
Hello everybody,
I have gotten a file in this way:
File f3=new File("H:\\results\\ext\\wrk\\"+sb+".xml");
Now I want to move this file to another directory for an example:
("H:\\results\\ext\\David\\);

Do anybody know how can I do it?

Thank you very much

David


Charles Bell

Posts: 519
Nickname: charles
Registered: Feb, 2002

Re: Moving a file to other directories Posted: Jun 20, 2002 3:44 PM
Reply to this message Reply
use the following method in the File class:


renameTo
public boolean renameTo(File dest)
Renames the file denoted by this abstract pathname.

Parameters:
dest - The new abstract pathname for the named file
Returns:
true if and only if the renaming succeeded; false otherwise
Throws:
SecurityException - If a security manager exists and its SecurityManager.checkWrite(java.lang.String) method denies write access to either the old or new pathnames
NullPointerException - If parameter dest is null

Flat View: This topic has 1 reply on 1 page
Topic: hello problem in this code want solution Previous Topic   Next Topic Topic: AudioInputStream problems

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use