i have 2 projects A and B in eclipse. B has dependency to A. In project开发者_如何学Go A is a text file "file.txt"
. This file can be loaded in project B by for example getClass().getResourceAsStream(...)
... because the location of the file is in classpath
. I want to provide this same file name in project B and do some action only if file exists in project B. If there is no file in project B then no file should be found during loading with getClass().getResourceAsStream(...)
. Currently the file will be always found.
Thank you for help.
Kind regards Sebastian
I need to provide a little bit more information about the problem. Sorry.
There is a project C which is the core. In project C there is class which do the following:
- Check if
file.txt
exists. This is the base code which checks only the file name. No package name. And i dont want to change it. - if yes then do something.
- if now then do something else.
A depends on C and B also depends on C. If A will be executed then the base code from C will be try to find file.txt
.
If B will be executed then the base code will be also try to find file.txt
. If there is no file in B project then it will found because it is in A. I dont want it.
Thank your very much.
Add the file in project B in a different classpath location, you try first the location in project B and then check the file in project A. Say the location is com.myPackage.file1 in project B and com.myPackage.projA.file1 in project A.
精彩评论