2 Replies Latest reply on Mar 6, 2008 4:34 AM by mars1412

    ear: read a file from webapplication

      how can I read a file from my webapplication?
      e.g. file is in project.ear\twentyfouract.war\img\mypic.gif

      File file = new File("img\mypic.gif");


        • 1. Re: ear: read a file from webapplication

          You may want to try ;

          URL fileURL = this.getClass().getResource("img\mypic.gif");
          


          • 2. Re: ear: read a file from webapplication

            tx for the reply
            actually I just looked into the seam source how the seam.properties file is read and came up with this solution:

            javax.faces.context.FacesContext facesContext = javax.faces.context.FacesContext.getCurrentInstance();
            ServletContext servletContext = (ServletContext)facesContext.getExternalContext().getContext();
            
            InputStream is = Resources.getResourceAsStream("img\mypic.gif", servletContext);