问题
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