Spaces in File path of a command
Hi all,
I have a problem in the following API
Runtime.getRuntime.exec
("open /var/root/Desktop/Test Folder/abc.jpg");
it does not open the file mentioned but the following command
Runtime.getRuntime.exec("open /var/root/Desktop/TestFolder/abc.jpg");
it opens the file abc.jpg. the only difference between these 2 commands is spaces in "Test Folder" directory name.
Please let me know if anybody has an idea.
thanks
Message was edited by:
nav_nini
[514 byte] By [
nav_ninia] at [2007-11-27 11:38:38]

("open \"/var/root/Desktop/Test Folder/abc.jpg\"");
Obviously, you need to quote the string that has spaces, since spaces on the command line normally demarcate the end of one argument and the beginning of the next.
Also note that to put a quote within a string, you must use:
"\""
e.g, this string printed out in cmd...
String text = "\"This is a quote\", he said";
would be: "This is a quote", he said
Just incase you didnt understand that from masijade's explanation.
I Have tested with the following
("open \"/var/root/Desktop/Test Folder/abc.jpg\"");
and
("open '/var/root/Desktop/Test Folder/abc.jpg' ");
and
("open /var/root/Desktop/Test\ Folder/abc.jpg");
But no success
thanks
Thank you all
Finally i got the solution.
use
String [] cmdArray option of
Runtime.getruntime().exec(String [] cmdArray )
Best regards
Naveen