我正在尝试将文本文件作为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 **
使用此选项时,JAR文件是所有用户类的源,而其他用户类路径设置将被忽略。
因此,其他类路径条目将被忽略。您将必须使用普通的旧java
命令,使用main方法指定一个类,并将您.jar
的类包括在类路径中。
您在清单中指定的相对路径是相对于JAR本身的,还是完整的URL。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句