[英]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.