This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

space in directory name  RSS feed

 
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: 23283
125
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!