3 Replies Latest reply on Apr 22, 2008 10:47 AM by mars1412

    how to load external files?

    nes

      i have a very large file that i'd like to load in my java code, for its too large to declare it as a constant. it contains lots of newlines, so id prefer to not make it a resource bundle. how can i load such a file?

        • 1. Re: how to load external files?
          kruno

          I am not sure that I understand.
          How big are we talking about 1 GB or more, and why would you whant it all in memory.

          • 2. Re: how to load external files?
            nes

            thanks for your answer. though it does make me wonder that whatever i do, people start questioning if im in my right mind.
            
            anyway, the answer to my question is something like this:
            
            assert(Thread.currentThread().getContextClassLoader()
                   .getResource("Xmldateibegin.txt") != null);
            
            which looks much like a testng test. WHICH WOULD WORK IF I GOT THIS FRACKING TESTNG STUFF RUNNING!!!1
            
            n.


            • 3. Re: how to load external files?

              maybe this helps


                        javax.faces.context.FacesContext facesContext = javax.faces.context.FacesContext.getCurrentInstance();
                        ServletContext servletContext = (ServletContext) facesContext.getExternalContext().getContext();
              
                        InputStream is = Resources.getResourceAsStream(filePath, servletContext);