1 回答

TA貢獻1818條經驗 獲得超8個贊
您可以使用下面的代碼使用 java 打開視頻,但這僅適用于 ubuntu 或其他 Linux。您還可以檢查您的操作系統并更改命令。對于 Windows,它只是文件名的絕對路徑。
public class Main
{
public static void main(String[] args)
{
Runtime runtime = Runtime.getRuntime();
try {
runtime.exec("xdg-open <path+yourfilename>");
} catch (IOException e) {
e.printStackTrace();
}
}
}
用于窗戶
public class Main
{
public static void main(String[] args)
{
Runtime runtime = Runtime.getRuntime();
try {
String[] command = {"cmd.exe", "/k", "Start", "<path+yourfilename>"};
Process p = runtime.exec(command);
} catch (IOException e) {
e.printStackTrace();
}
}
}
添加回答
舉報