java - Cant load xml from the same folder as class -
i'm pretty new java, i've started code few weeks ago, please patient me :)
i want send xml file through http post request, , i'm able simulate perfectly, problem when dont create xml, have xml, on same level class, , cant seem use it, no matter do, path put in, cant file load.
example: have class caleld sendpostrequest.class, on same directory have details.xml, i'm trying to:
getclass().getresource("details.xml"); // returns null i've tried every other combination, full path, or patfrom path throughsystem.getproperty("user.dir"); and nothing, wont load.
i'm sure i'm missing silly, i'm using intellij, there shortcut doing this??? starters, want load xml string, print out see working...
many in advance!
do perhaps build maven? reason ask because had same weird problem, couldn't load .xml file, because wasn't included in built jar, why? should be.... hmm after bit of troubleshooting ended in pom.xml , turns out resources file extension*.xml wasn't included in build.
<project> ... <build> ... <resources> <resource> ... <includes> <include>**/*.xml</include> </includes> </resource> after adding file extension in snippet above fine, xml file built in jar , access resource. don't know if case shitty little include did mess couple of hours me...
Comments
Post a Comment