How to tell java to ignore spaces

走远了吗. 提交于 2019-12-23 07:02:32

问题


I have a string that I am trying to execute. The string contains a path to a MacOS .x file, which has a space in the path name. When I run it Java is telling me that it cannot run the program.

"/Users/brianallison/Documents/Java/RELAP5 GUI/issrs/dist/relap5.x" -i "Choose your input file" -r "" -o ""

May 08, 2015 2:19:37 PM my.issrs.issrsUI btnRunRelapActionPerformed SEVERE: null java.io.IOException: Cannot run program "/Users/brianallison/Documents/Java/RELAP5": error=2, No such file or directory

I have tried putting quotes around the path, but Java is ignoring the quotes. As you can see on the first line that is how it supposed to go, but Java is cutting it off at RELAP5.


回答1:


Try to escape space with back slash:

"/Users/brianallison/Documents/Java/RELAP5\ GUI/issrs/dist/relap5.x" -i "Choose your input file" -r "" -o ""


来源:https://stackoverflow.com/questions/30132297/how-to-tell-java-to-ignore-spaces

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