title: Load java.io.File At Runtime On Classpath
body: <p>I have two jars (main.jar and schema.jar) and I need to read a schema file (located in src/main/resources/sample.xsd) from schema.jar in a class within main.jar.  main.jar has schema.jar on its classpath as a maven dependency. I'm able to find the sample.xsd file when I use the this.getClass().getClassLoader().getResourceAsStream, but I need a java.io.File.  What is the most memory efficient approach to supply the java.io.File parameter?</p>
  
  <p><strong>main.jar:</strong></p>
  
  <pre><code>InputStream in = this.getClass().getClassLoader()
          .getResourceAsStream("/resources/sample.xsd");
  
  Sample sample = new Sample();
  //set sample data here
   Marshaller marshaller = JAXBContext.newInstance(Sample.getClass()).createMarshaller();
      final SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
      final Schema s = schemaFactory.newSchema(new File("/resources/sample.xsd"));
  marshaller.setSchema(s);
      marshaller.marshal(Sample, XML);
  </code></pre>