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