Link to home
Start Free TrialLog in
Avatar of allelopath
allelopath

asked on

getRuntime().exec() problem

In the line below, filename is a String that is the path and filename of an excel file. This works (ie the file is displayed in Excel), except when there is a space in the path. How can this be fixed?

Runtime.getRuntime().exec(new String[] { "cmd.exe", "/c", "start", filename });

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Gurvinder Pal Singh
Gurvinder Pal Singh
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Try this:
Runtime.getRuntime().exec(new String[] { "cmd.exe", "/c", "start", "\"" + filename + "\"" });
Avatar of allelopath
allelopath

ASKER

From the link, this works:
String[] commands = {"cmd", "/c", "start", "\"DummyTitle\"",fileName};

That DummyTItle is necessary, doesn't work without it. What does it do?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial