Read a xml file in a .jar

Discussions

EJB programming & troubleshooting: Read a xml file in a .jar

  1. Read a xml file in a .jar (2 messages)

    hi all:

    A xml file and some ejb classes are packed in a jar file.
    In my class I want to read the xml file, just like
    new FileInputStream("error-map.xml");
    But how can I get the file path and the file resource?

    thanks in advance

    ray

    Threaded Messages (2)

  2. Read a xml file in a .jar[ Go to top ]

    You can use Class.getResourceAsStream(filename) which gives you an InputStream.

    David
  3. Read a xml file in a .jar[ Go to top ]

    thanks a lot
    I get it
    getClass().getClassLoader().getResourceAsStream("com/espacesoft/exception/error-map.xml")


    thanks again