[英]Java binary not picking up resources from the specified class path
我正在嘗試將文本文件作為InputStream加載,但是txt文件從未被拾取,並且輸入流的值始終為null 。 我不知道為什么會這樣,我想尋求幫助。
nohup java -jar crawler-jar-2014.11.0-SNAPSHOT.jar -classpath /home/nbsxlwa/crawler/resources/common-conf:/home/nbsxlwa/crawler/resources/dotcom-conf:./plugins/*:./lib/* &
txt文件位於/home/nbsxlwa/crawler/resources/dotcom-conf
目錄中。 我可以確認該文件確實存在,所以我不知道為什么未提取該文件。 設置如下:
`System.getEnvironment( “java.class.path”)
返回以下值crawler-jar-2014.11.0-SNAPSHOT.jar
代碼塊正在嘗試創建文本輸入流。
String fileRules = conf.get(URLFILTER_REGEX_FILE); System.out.println("file rules = " + fileRules); // Pass the file as a resource in classpath. // return conf.getConfResourceAsReader(fileRules); // Pass the file as a resource in classpath. InputStream is = RegexURLFilter.class.getResourceAsStream("/" + fileRules); System.out.println("Inputstream is = " + is); System.out.println(ClassLoader.getSystemResourceAsStream(fileRules));
以上代碼段的輸出是
file rules = regex-urlfilter.txt
Inputstream is = null
null
類路徑:資源/ common-conf資源/ dotcom-conf資源/ olb-conf lib / gora-cassandra-0.3.jar **其他JARS **
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.