1

From test.java, how can I access for reading the Contact.xml file located in the contacts.jar library ?

The bellow code returns null.

package views;

import fr.hznteam.contacts.Contact;
import fr.hznteam.errors.ResourceException;

import java.io.InputStream;


    public class Test {

        private static final String TAG = "Test ";

        public static void main(String[] args) throws ResourceException {

            InputStream is = Contact.class.getResourceAsStream("/fr/hznteam/contacts/sql/Contact.xml");
            System.out.println(TAG + "resource from jar " + is);

        }

The package structure :

enter image description here

Emmanuel BRUNET
  • 1,286
  • 3
  • 19
  • 46

1 Answers1

0

this works (see above comment). Inside an object instance use

getClass().getResourceAsStream("/absolute/class_path/to/resource.file"))
Emmanuel BRUNET
  • 1,286
  • 3
  • 19
  • 46