This week's giveaway is in the Threads forum.
We're giving away four copies of Java Concurrency Live Lessons and have Doug Schmidt on-line!
See this thread for details.
Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Moving file to specific folger  RSS feed

 
Raj Miandad
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
this is my first post. I have a task in hand. I got to transfer a .zip file which i receive through another method and store it in a folder structure accordingly. The problem is, I am having trouble with moving this file to the folder. Can anyone help me here?

And while making a new directory, cant several new folders be created at once? What i mean is that, for instance, make a new folder "C:/test/test1/test2" where test,test1 and test2 dont exist? Do we have to create one folder at a time until reaching the final folder?(test2).

Kindly reply.
 
Rob Spoor
Sheriff
Posts: 20904
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out the following two methods:
java.io.File.mkdirs() - note the trailing s
java.io.File.renameTo(java.io.File)

The latter does not merely rename, but can also move files. The extent as to where you can move it may depend on your operating system, but in Windows XP I've been able to move files across partitions, and if I remember correctly even to remote shares.
 
Raj Miandad
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot.....it works perfectly fine
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!