• Post Reply Bookmark Topic Watch Topic
  • New Topic

space in directory name

 
Ann Bar
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My program can not move a file to a directory. The directory has spaces in its name. How do I convert the path name to something that my program can recognize? This is the command I execute:

String command = "cmd /c move " + file + " " + destDir;

Thanks.
 
Henry Wong
author
Sheriff
Posts: 22518
109
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ann Bar:
My program can not move a file to a directory. The directory has spaces in its name. How do I convert the path name to something that my program can recognize? This is the command I execute:

String command = "cmd /c move " + file + " " + destDir;

Thanks.


You are using the version of the exec(String cmd) method that take a single string command. It separates the paramaters (incorrectly) using space as a delimiter.

You can break the command into the parameter yourself, and use the array version of the exec(String cmd[]) method.



Henry
 
Ann Bar
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks you Henry. That solved my problem!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!