public CLASSIFIER_TYPE createClassifier() throws IOException { InputStream stream = this.getClass().getResourceAsStream(this.classifierJarPath); if (stream == null) { try { stream = new URL(this.classifierJarPath).openStream(); } catch (MalformedURLException e) { stream = new FileInputStream(this.classifierJarPath); } } stream = new BufferedInputStream(stream); JarInputStream modelStream = new JarInputStream(stream); JarClassifierBuilder<?> builder = JarClassifierBuilder.fromManifest(modelStream.getManifest()); try { return this.getClassifierClass().cast(builder.loadClassifier(modelStream)); } finally { stream.close(); } }