By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,110 Members | 1,010 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,110 IT Pros & Developers. It's quick & easy.

trailing space in argument of Runtime.getRuntime().exec(arg[]),

P: n/a
aa
Anybody know the solution to trailing space in argument of
Runtime.getRuntime().exec(arg[]),
Process p = Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler
C:\\Documents and Settings\\XX\\Desktop\\- Copy of TestingFolder -\\jjjj
hihi.doc");

where there is 2 space between dash and "Copy of TestingFolder", but after
going through Runtime.getRuntime().exec(arg[]), it chopes off one space and
make me can't open the file.

Any help, anyone experienced it before, thank you.
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Wed, 13 Aug 2003 18:17:23 +0800, "aa" <aa@aa.com> two-finger typed:
Anybody know the solution to trailing space in argument of
Runtime.getRuntime().exec(arg[]),
Process p = Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler
C:\\Documents and Settings\\XX\\Desktop\\- Copy of TestingFolder -\\jjjj
hihi.doc");

where there is 2 space between dash and "Copy of TestingFolder", but after
going through Runtime.getRuntime().exec(arg[]), it chopes off one space and
make me can't open the file.

Any help, anyone experienced it before, thank you.


Looks to me like you forgot the extra quotes around the argument starting
with C:
If you do Start -> Run and type the line there, it would look to rundll32
as if you gave five arguments, not the one. The same happens with exec().
Both see a total of 6 parameters:
url.dll,FileProtocolHandler
C:\\Documents and Settings\\XX\\Desktop\\-
Copy
of
TestingFolder
-\\jjjjhihi.doc

With quotes it would look like this:

Process p = Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler
\"C:\\Documents and Settings\\XX\\Desktop\\- Copy of TestingFolder -\\jjjj
hihi.doc\"");

And both exec (I hope) as well as rundll32 see the entire file location as
a single parameter.
Cheers.
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.