• Post Reply Bookmark Topic Watch Topic
  • New Topic

move files from one directory to other

 
shiva mistry
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi when I am trying to move files from one directory to other in following code ,it says it copied files to outdir, but i do not see any files in output folder.like at line 40 if I specify particular path like "E:\\b\\" for output folder ,it copies file to that folder but when i try to pass same path from outside via File outdir ,my files remain in same folder ,can anyone help please ?


 
Paul Clapham
Sheriff
Posts: 21892
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your confirmation message isn't very helpful, because it doesn't tell you what the value of the expression outdir + f.getName() is. I think you're making an assumption which isn't correct.

But anyway, if you want to make a File object which represents a file named X in directory Y, then concatenating Y + X isn't the clearest or most reliable way to do that. There's a File constructor specifically for that: new File(File parent, String child).
 
Mike Simmons
Ranch Hand
Posts: 3090
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The renameTo() method returns a boolean, indicating success or failure. What value is it returning? You should get that value and record it.

Also, it's helpful to do something like

to find out, for sure, exactly where your program thinks the file is.
 
shiva mistry
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks @Paul ,Thanks @ Mike
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!