private File getTemplateFile ( String filename ) throws IOException { File templateFile = null ; final String resource = TEMPLATE_RESOURCES_PATH + "/" + filename ; InputStream is = Setup . class . getClassLoader ( ) . getResourceAsStream ( resource ) ; if ( null == is ) { throw new RuntimeException ( "Unable to load required template: " + resource ) ; } templateFile = File . createTempFile ( "temp" , filename ) ; templateFile . deleteOnExit ( ) ; try { return copyToNativeLineEndings ( is , templateFile ) ; } finally { is . close ( ) ; } }
Look for template in the jar resources otherwise look for it on filepath