Open PDF file on the fly from a Java application

前端 未结 6 1867
逝去的感伤
逝去的感伤 2020-12-01 09:06

Is there any way to have a code that opens a PDF file in Java application in a platform independant way? I mean using a batch file in Windows could do that. Is there any oth

6条回答
  •  抹茶落季
    2020-12-01 09:35

    Use this code to open a specific file:

    String cmds[] = new String[] {"cmd", "/c", "C:\\Users\\PC\\Desktop\\EA01.pdf"};
    try {
        Runtime.getRuntime().exec(cmds);
    }
    

提交回复
热议问题