I use FlatPack to analyze and load data from flat files. This requires loading a configuration file that stores the column mappings of the flat file.
I have a constant for locating the mapping file:
private static final String MAPPING_FILE = "src/com/company/config/Maping.pzmap.xml";
I have a parse (File dataFile) method that actually parses:
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();
When I crack everything and run it like a jar - it explodes on FileReader mappingFileReader = new FileReader(MAPPING_FILE); using FileNotFoundException . However, this file is inside the jar.
How do I get to it?
I looked at this question and this question about accessing files inside jars, and they both recommend temporarily extracting the file. I do not want to do this.
java jar
Owen
source share