I am working with Intellij and my XML file is in the below path -
C:\workspace\one\two\three\src\main\java\com\package\serv\ap\versionOne\fine.xsd
Now I am trying to read this XML file as I need to make StreamSource
object from it. When I use absolute path, then it works fine -
StreamSource XSD = new StreamSource(new File("C:\\workspace\\one\\two\\three\\src\\main\\java\\com\\package\\serv\\ap\\versionOne\\fine.xsd"));
But the above is not the right way to do it as it will not work in other machines. So I tried using getResourceAsStream
but that doesn't work for me as I get everything as null inside StreamSource
object
StreamSource XSD = new StreamSource(this.getClass().getResourceAsStream("fine.xsd"));
Is there anything wrong I am doing while trying to load xml file?