Accessing a resource within a jar (working in Netbeans but not on command line)

前端 未结 2 564
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-26 21:07

I have a jar file with bundled resources (language model binary files) that need loading at run time. The directory structure within the jar is

tagger/app.class
tag

2条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-26 21:15

    You can't access a resource in a Jar file via java.io.File. You should provide an alternate constructor for SentenceDetector which either accepts an InputStream rather than a String, or which accepts an URL and uses URL.openStream() to get an InputStream.

提交回复
热议问题