简体   繁体   中英

Get URL of the file streamed by InputStream

Models.jar contain the file cmudict, this jar file is added as class path to the project

InputStream in = this.getClass().getResourceAsStream("edu/cmu/sphinx/language/cmudict");

Above statement accesses the file cmudict Stream, but I want to print the complete URL of the file location, which also includes the location of Models.jar file.

How this can be achieved?

This can be achieved very easy:

URL resource = this.getClass().getResource();

Have a look at the API for more informations @see http://docs.oracle.com/javase/8/docs/api/java/lang/Class.html#getResource-java.lang.String-

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM