Java - ProcessBuilder command arguments with spaces and double-quotes fails

孤街醉人 提交于 2019-11-29 08:05:18
Jayan

Add individual strings without "double" quotes..

                commands.add ( "C:\\Program Files\\CCBU\\CCBU.exe"                      );
                commands.add ( "-d");
                commands.add ("C:\\My Data\\projects\\ccbu\\ciccb-report.xls"        );
                commands.add ( "-tf");
                commands.add("C:\\Program Files\\CCBU\\loss-billing-filters.txt"   );
                commandExecutor = new SystemCommandExecutor(commands);

ProcessBuilder will take care of necessary handling of args.


Pull up comment:

Jayan, You're idea got me thinking : The following worked :

 commands.add ( "-dC:\\My Data\\projects\\ccbu\\ciccb-report.xls" );
 commands.add ( "-tfC:\\Program Files\\CCBU\\loss-billing-filters.txt"

); – lincolnadym

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!