0

I have a java desktop application need to copy a directory to another location.so I've used the

Runtime.exec();

to execute the cmd command

xcopy H:\Source* L:\MY Folder /e /i

but when there is a space in a folder name like

MY Foloder

It returns and error.so how to avoid this .. Any help!

5
  • I would recommend you implement a Java directory copy and avoid spawining a shell. For one thing, your program is now Windows only. Aug 29, 2014 at 4:10
  • Yes windows only..just tell me why the space is affecting ?
    – Sniper
    Aug 29, 2014 at 4:18
  • see if this one helps: stackoverflow.com/a/17141811/1043824 Aug 29, 2014 at 4:20
  • Elliott Frisch save me a lot.thanks bro..
    – Sniper
    Aug 29, 2014 at 4:45
  • You have to escape the space and the backslashes. But what you have here doesn't work on the command line if you run it without java. Aug 29, 2014 at 5:04

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.