如何用Java使用WindowsPhotoGallery显示gif图像?
我使用下面的代码通过调用运行时命令在Java中显示gif图像,它打开WindowsPhotoGallery,但不显示我的图像,而是显示我的PC上的一堆其他图片,我的问题是:如何通过正确指定 gif 图像文件名,这样它将以我的图像打开。
现在我像这样传递它: C:\Program Files\Windows Photo Gallery\WindowsPhotoGallery "C:/abc.gif"
哪个不正确,正确的方法是什么?
String Command,Program,File_Path="C:/abc.gif";
Process process=null;
Program="C:\\Program Files\\Windows Photo Gallery\\WindowsPhotoGallery ";
Command=Program+"\""+File_Path+"\"";
try { process=Runtime.getRuntime().exec(Command); }
catch (Exception e) { e.printStackTrace(); }
I use the following code to display a gif image in Java by calling a runtime command, it opens the WindowsPhotoGallery, but doesn't display my image, instead it shows a bunch of other pictures on my PC, my question is : how to pass the gif image file name to it properly, so it will open with my image.
Now I'm passing it like this :
C:\Program Files\Windows Photo Gallery\WindowsPhotoGallery "C:/abc.gif"
Which is incorrect, what's the right way to do it ?
String Command,Program,File_Path="C:/abc.gif";
Process process=null;
Program="C:\\Program Files\\Windows Photo Gallery\\WindowsPhotoGallery ";
Command=Program+"\""+File_Path+"\"";
try { process=Runtime.getRuntime().exec(Command); }
catch (Exception e) { e.printStackTrace(); }
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用
Runtime.exec(String[] cmdArray)
传递命令及其参数。You can use
Runtime.exec(String[] cmdArray)
to pass a command and its arguments.问题出在命令行字符串中。
例如:c:\document 和设置\pic.gif = "\"c:\document 和设置\pic.gif\""
The problem is in the command line string.
for example : c:\document and settting\pic.gif = "\"c:\document and setting\pic.gif\""