I need an xml file to be accessed via the classpath in a java application i am creating . how to achieve it in eclipse
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
I'd generate a separate resources folder, right-click it and select Build Path > Use as Source Folder
. That way it's on the class path, but you're not mixing it with your Java source files
回答2:
Put it in java source folder, and use it as resource
回答3:
Put the directory containing the XML in the runtime classpath, then use className.Class.getResourceAsStream()
to get an InputStream containing the XML.