Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within I/O and Streams
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
I/O and Streams
What s wrong in this file program to move a file to directory
Vinney Shanmugam
Ranch Hand
Posts: 104
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
import java.io.File; public class moveFile { public static void main(String args[]){ try{ // File (or directory) to be moved File file = new File("file.txt"); // Destination directory File dir = new File("d:\\myDirectory"); // Move file to new directory boolean success = file.renameTo(new File(dir, file.getName())); if (!success) { System.out.println("File was not moved"); } } catch (Exception ioe){ ioe.printStackTrace(); } } }
file is not getting moved...
Joe Ess
Bartender
Posts: 9626
16
I like...
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I don't see anything obviously wrong.
Does file.txt exist in the directory you are running the program from?
Is file.txt currently in use?
Does d:\myDirectory exist and do you have permission to write to it?
[
How To Ask Questions On JavaRanch
]
Don't get me started about those stupid
light bulbs
.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
moving files to different folders
renameTo()
How to copy PDF/Ms Word file to another directory
Need help with moving file from one directory to other
Problem in moving file
More...