Java execute a command with a space in the pathname

后端 未结 4 1739
悲&欢浪女
悲&欢浪女 2020-11-27 06:32

How can I execute a Java System (shell) command that has a space in the pathname?

I\'ve tried putting quotes and a backslash (), But it does not work.



        
4条回答
  •  旧时难觅i
    2020-11-27 07:03

    You can use it in the following way without having to introduce any backslashes: Runtime.getRuntime().exec(new String[]{"ln", "-s", "dir1/dir2", "my dir/dir2"});

提交回复
热议问题