reference to txt file in jar


General J2EE: reference to txt file in jar

  1. reference to txt file in jar (2 messages)

    Hi all,

    I am trying to make a reference to a config file that is located in a jar.
    I am doing this by te following: file = new FileInputStream(sConfigFileName);
    where the sConfigFileName is supposed be the path to the config file. But what I want to do is reference to a file in a jar. Does anybody know what to give as path to the config file?



    Threaded Messages (2)

  2. reference to txt file in jar[ Go to top ]

    Try using Class.getResourceAsStream().

  3. mmmm[ Go to top ]

    doesnt seem to work...

    I read the file as follows:

    FileInputStream file = (FileInputStream)this.getClass().getResourceAsStream(sConfigFileName);

    sConfigFileName is the string : config.txt

    The file is located at the root of the jar file...