Runtime.exec on argument containing multiple spaces

前端 未结 8 859
闹比i
闹比i 2020-11-30 15:15

Can anyone make the following run?

public class ExecTest {
  public static void main(String[] args) {
    try {
      //Notice the multiple spaces in the arg         


        
8条回答
  •  暖寄归人
    2020-11-30 15:29

    For your specific case of needing the reveal/select command, I get around the windows quote nightmare by using cmd /c start:

    String[] cmd = {"cmd", "/c", "start explorer.exe /select," + path};
    

    Where path is the absolute path from a File object.

提交回复
热议问题