阅读图像时出现问题

时间:2014-01-15 15:23:57

标签: java image file bufferedimage

我在阅读图片时遇到问题,图片位于src / iamges / logo.jpg ............

JFreeChart jfreechart = ChartFactory.createGanttChart("Actividades", "Actividad", "Fecha", cratedataSet(getListaactividades()));

BufferedImage img = ImageIO.read(new File("/src/demo/logiepn.jpg"));
jfreechart.setBackgroundImage(img);

File chartFile = new File("dynamichart");  

   ChartUtilities.saveChartAsPNG(chartFile, jfreechart, 720, 400);  
   chart = new DefaultStreamedContent(new FileInputStream(chartFile), "image/png");  

,错误是:

Caused by: javax.imageio.IIOException: Can't read input file!
    at javax.imageio.ImageIO.read(ImageIO.java:1275) [rt.jar:1.6.0_21]
    at ec.edu.epn.proyectos.backingbean.proyectosAprobados.InformeProycierreproy(proyectosAprobados.java:227) [classes:]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.6.0_21]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [rt.jar:1.6.0_21]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [rt.jar:1.6.0_21]
    at java.lang.reflect.Method.invoke(Method.java:597) [rt.jar:1.6.0_21]
    at org.apache.el.parser.AstValue.invoke(AstValue.java:264) [jbossweb-7.0.17.Final.jar:]
    at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278) [jbossweb-7.0.17.Final.jar:]
    at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105) [jsf-impl-2.1.11-jbossorg-3.jar:]
    at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88) [jboss-jsf-api_2.1_spec-2.0.4.Final.jar:2.0.4.Final]

1 个答案:

答案 0 :(得分:0)

你的道路错了,看看这个问题的答案:

Load Java Image inside package from a class in a different package