簡體   English   中英

獲取InputStream流式傳輸的文件的URL

[英]Get URL of the file streamed by InputStream

Models.jar包含文件cmudict,此jar文件作為類路徑添加到項目中

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

Stream, but I want to print the complete URL of the file location, which also includes the location of Models.jar file. 上面的語句訪問文件 Stream,但是我想打印文件位置的完整URL,其中還包括Models.jar文件的位置。

如何做到這一點?

這可以很容易地實現:

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

看一下API以獲得更多信息@see http://docs.oracle.com/javase/8/docs/api/java/lang/Class.html#getResource-java.lang.String-

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM