title: How do I access a config file inside the jar?
body: <p>I'm using <a href="http://flatpack.sourceforge.net/" rel="nofollow noreferrer">FlatPack</a> to parse and load data from flat files.  This requires loading a config file that stores mappings of the columns of the flat file.</p>
  
  <p>I have a constant to define the location of the mapping file:</p>
  
  <pre><code>private static final String MAPPING_FILE = "src/com/company/config/Maping.pzmap.xml";
  </code></pre>
  
  <p>I have a parse(File dataFile) method that actually does the parsing:</p>
  
  <pre><code>private void parse(File dataFile) throws FileNotFoundException, SQLException {
          Parser parser;
  
          log.info("Parsing " + dataFile.getName());
  
          FileReader mappingFileReader = new FileReader(MAPPING_FILE);
          FileReader dataFileReader = new FileReader(dataFile);
  
          parser = DefaultParserFactory.getInstance().newFixedLengthParser(mappingFileReader, dataFileReader);
          parser.setHandlingShortLines(true);
  
          DataSet dataSet = parser.parse();
  
          //process the data
  }
  </code></pre>
  
  <p>When I jar up everything and run it as a jar - it bombs out on <code>FileReader mappingFileReader = new FileReader(MAPPING_FILE);</code> with a <code>FileNotFoundException</code>.  That file is inside the jar though.</p>
  
  <p>How do I get to it?</p>
  
  <p>I've looked at <a href="https://stackoverflow.com/questions/600146/run-exe-which-is-packaged-inside-jar">this question</a> and <a href="https://stackoverflow.com/questions/463972/creating-a-new-file-using-an-existing-file-within-a-jar">this question</a> about accessing files inside jars and they both recommend temporarily extracting the file.  I don't want to do that though.</p>