如何将图像和xml文件上传到eclipse中的maven项目中 [英] How to upload images and xml file into a maven project in eclipse
问题描述
将文件放在源文件夹资源中,并将它们不作为文件访问,但作为
URL url = getClass()。getResource(/ a / b / c.png);
// URL..... myproject.jar!/ a / b / c,png
或直接作为:
InputStream in = getClass()。getResourceAsStream(/ d.xml);
区分大小写。
这些文件与jar文件中的.class代码一起。
I'm working on a videogame with a my friend. We are working with Eclipse and we are using maven. We use BitBucket to synchronize the project but now we have a problem. I'm doing the GUI but I don't know how to upload the images and an xml file in the project and synchronize this with bitbucket. Now I'm using the path of the file that is on my desktop. There is a way to load all the files and import these into the project? I'm searching a solution that is correct also when we must export the project in a jar file.
Place the files in the source folder resources, and access them not as File, but as
URL url = getClass().getResource("/a/b/c.png");
// URL "..... myproject.jar!/a/b/c,png"
or direct as:
InputStream in = getClass().getResourceAsStream("/d.xml");
Case-sensitive.
This zips the files together with the .class code in the jar file.
这篇关于如何将图像和xml文件上传到eclipse中的maven项目中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!