It is actually very correct. Absolute classpath like a file resource is not supported in OSGi, nor should you rely on it, you can get around it in equinox, but containers like Knoplerfish will deliver even resources from RAM.
So you want to use getting it as a resource, not a file. On Jul 7, 2011, at 6:10 PM, shamik wrote: > Hi, > I'm trying figure a way to get the absolute path of files located under my > project's resource folder. The file paths are injected through spring as : > > <property name="siteConfig" value="classpath:/Test/test.xml" /> > > The directory is located under src/main/resources folder, which makes it > available as a classpath resource inside the bundle. > > The property is being set as a Spring Resource object inside the java class. > I'm trying to access the file following way : > > File testFile = new File(siteConfig.getURL().getPath()); > > I'm passing this File object to another program which then reads it. > > siteConfig.getURL() --> bundle://249.14:1/TEST/test.xml > > testFile.getAbsolutePath() --> C:\TEST\test.xml . > > As you can see, the absolute path is just repalcing "bundle://249.14:1" with > "C:\", which is incorrect. As a result, when the program is trying to read > the file, it's not able to pick it up. > > Any pointers will be appreciated. > > - Thanks > > -- > View this message in context: > http://servicemix.396122.n5.nabble.com/How-to-get-absolute-classpath-of-a-file-tp4562967p4562967.html > Sent from the ServiceMix - User mailing list archive at Nabble.com.
