[英]Access denied when opening WMV file from Java application
I wrote this code in my Java application:我在我的 Java 应用程序中编写了这段代码:
URL url = new URL("file://c:\\tmp\\test.wmv");
java.awt.Desktop.getDesktop().browse(url.toURI());
If I execute it, Java throws an "access denied" IOException.如果我执行它,Java 会抛出一个“访问被拒绝”的 IOException。 Permissions are OK on that file.
该文件的权限没问题。 I renamed that file to "test.txt" so it just has another extension.
我将该文件重命名为“test.txt”,因此它只有另一个扩展名。 The result: Notepad opens and shows me the bytes of the file.
结果:记事本打开并向我显示文件的字节数。 So it is a problem in executing the media player.
所以这是执行媒体播放器的问题。 I configured the extension settings, so the media player opens when I click on the file in Windows Explorer.
我配置了扩展设置,因此当我在 Windows 资源管理器中单击文件时媒体播放器会打开。 But it's not possible for Java to use this Defaultprogram for the wmv-extension.
但是 Java 不可能将此 Defaultprogram 用于 wmv-extension。 What can I do?
我能做什么?
URL url = new URL("file://c:\\tmp\\test.wmv");
java.awt.Desktop.getDesktop().browse(url.toURI());
Should be more along the lines of:应该更多地遵循以下原则:
File file = new File("c:\\tmp\\test.wmv");
java.awt.Desktop.getDesktop().open(file);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.