开发者

Finding paths for packaged non-java files at runtime

开发者 https://www.devze.com 2022-12-17 15:52 出处:网络
So this might be a stupid question but... I want to package a specific WSDL file in with an EJB project within eclipse.开发者_如何学C What would be the best way to refer to this file in my code?

So this might be a stupid question but...

I want to package a specific WSDL file in with an EJB project within eclipse.开发者_如何学C What would be the best way to refer to this file in my code?

I would like to use a relative path but the current directory starts off in the /bin directory of my JBOSS installation. It seems like there should be a way to refer to the file in relation to the project file structure.

Any ideas?


getClass().getResource(String path) uses a relative path to locate a classpath resource. It returns a java.net.URL. Alternatively, you can use getResourceAsStream(..) to obtain the InputStream to the resource.

0

精彩评论

暂无评论...
验证码 换一张
取 消