• Post Reply Bookmark Topic Watch Topic
  • New Topic

Help me to Move File From One Place to Another  RSS feed

 
Raks Kumar
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear friend
I want to move file from one place to another place.
It should be in Java.I am trying but unable to do it.
Plese provide me code for it. It is urgent.
Thanks
Raks
 
Mani Ram
Ranch Hand
Posts: 1140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check the renameTo method in java.io.File class.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

Please provide some more details so that we can help you. What is "one place", and what is "another place"? Through what means do you have access to either one of them?

It could be simple as using the java.io.File.renameTo method, which despite its name can move files.

Also, what do you mean by "I am unable to do"? What have you tried, and what happened? Post some code so we can see what you have so far.
[ January 30, 2006: Message edited by: Ulf Dittmer ]
 
Raks Kumar
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Friends
I write code below

File file=new File("\\192.168.0.15\\c$\\Rep\\01072006\\Release\\002_8_120_01072006.xml");
String DirectoryPath="\\192.168.0.15\\c$\\Rep\\01072006\\Sent\\";
(new File (DirectoryPath)).mkdirs();
File dir=new File(DirectoryPath);
file.renameTo(new File(dir,file.getName()));


If path Like This(c:\\Rep\\01072006\\.......)

It would be work fine but problem in path with IP address

Here Directory Create but not moved Why?
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the error message you're getting? Can you move the file by hand?
[ January 30, 2006: Message edited by: Ulf Dittmer ]
 
Sameer Damle
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi raks,

map this drive \\192.168.0.15\\c$ to the machine from where you are trying to move the files.

this should work....
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!