简体   繁体   English

从 Java 应用程序打开 WMV 文件时访问被拒绝

[英]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.

相关问题 从Java应用程序打开文件选择窗口 - Opening a file selection window from a java application EBS中的Amazon RDS实例:从Tomcat中的Java应用程序尝试访问时被拒绝 - Amazon RDS instance in EBS: Access Denied when trying from Java application in Tomcat 如何使用Java分割WMV文件 - How to split wmv file with java 安装到C:/ Program Files时,Java应用程序无法写入/读取序列化文件-java.io.FileNotFoundException :(拒绝访问) - Java application cannot write/read serialization file when installed to C:/Program Files - java.io.FileNotFoundException: (Access is denied) 上传文件时java.io.FileNotFoundException(路径)(访问被拒绝) - java.io.FileNotFoundException (path)(Access is denied) when uploading file 尝试从 C:\ProgramData 访问文件时出现“拒绝访问” - Getting 'Access Denied' when trying to access file from C:\ProgramData 使用 java 应用程序解压缩时文件权限被拒绝,手动工作正常 - File permissions denied when unzipped with java application, manually works fine 当访问被拒绝时,Java Files.copy删除文件 - Java Files.copy deletes file when access denied Java 写入文件 - 访问被拒绝 - Java writing file - Access is denied Java - 文件写入 - 访问被拒绝 - Java - file writing - access denied
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM