gpt4 book ai didi

java - 以可移植的方式以编程方式打开文档

转载 作者:可可西里 更新时间:2023-11-01 11:21:12 26 4
gpt4 key购买 nike

下面的命令在Unix&Linux下是否有效?

ProcessBuilder prcbdoc = new ProcessBuilder("cmd","/C","start", "Documentation.doc");       
prcbdoc.directory(new File(currentDir+"/docs/"));
prcbdoc.start();

我不确定,因为 "cmd""/c"

欧元:

什么是 Linux CentOS 等效命令?

最佳答案

不,它不起作用。来自 Java 文档:

a command, a list of strings which signifies the external program file to be invoked and its arguments, if any. Which string lists represent a valid operating system command is system-dependent. For example, it is common for each conceptual argument to be an element in this list, but there are operating systems where programs are expected to tokenize command line strings themselves - on such a system a Java implementation might require commands to contain exactly two elements.

使用 AWT 以便携方式打开文档:

if (Desktop.isDesktopSupported())
Desktop.getDesktop().open(documentPath);

关于java - 以可移植的方式以编程方式打开文档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9684943/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com