java中怎样打开一个图片文件
本帖最后由 chaozi2010 于 2010-04-20 18:27:56 编辑
How would you go about opening an image file called picture.jpg
A:Graphics.getGraphics("pricture.jpg");
B:Image img = Toolkit.getDefaultToolkit.getImage("pricture.jpg");
C:Graphics.openImage("pricture.jpg");
D:Image img = new Image("pricture.jpg");
------解决方案--------------------URL url= Thread.currentThread().getContextClassLoader().getResource("yourPackeage/pricture.jpg");
File file=new File(url.getFile());
yourPackage is a java package where your image is at