[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [equinox-dev] How to get files in bundle's classpath
|
If code resources might be in a jar, and you need a file: URL, you can also use FileLocator.toFileURL()
Tom
On 8/12/06, Thomas Watson <
tjwatson@xxxxxxxxxx> wrote:
Jerry,
You can use the following calls on a
Class object to see where they came from.
Class.getProtectionDomain().getCodeSource().getLocation()
HTH
Tom
|
To
| "Equinox development mailing list"
<equinox-dev@xxxxxxxxxxx>
|
cc
|
|
Subject
| Re: [equinox-dev] How to get files in
bundle's classpath |
|
Thanks for Edward's reply,but I mean is that I want
to get the
absolutePath of bundle's compile path,for example:
The class of bundle a project compiled to bin folder,now I want to use
some method to get the absolutePath of bin folder,how can I do that?
I have tried use
context.getClass().getClassLoader().getResource(""),this method
return
null.
2006/8/12, Edward Yakop <edward.yakop@xxxxxxxxx>:
> The real question is what do u want to do with it.
>
> I.e.
> URL url = "">
> InputStream inputStream = url.openStream();
>
> If config.file is a property file.
> Properties properties = new Properties();
> try
> {
> properties.load( inputStream );
> } catch( IOException e )
> {
> e.printStackTrace();
> }
>
> If config.file is an xml file.
> SaxParserFactory factory = SaxParserFactory().
> SaxParser parser = factory.newSAXParser();
>
> try
> {
> parser.parse( inputStream, defaultHandler ); // defaultHandler
is
> your sax default handler
> } catch( IOException e )
> {
> e.printStackTrace();
> } catch( SAXException e )
> {
> e.printStackTrace();
> }
>
> Regards,
> Edward
>
> On 8/12/06, jerry lin <bluedavy@xxxxxxxxx> wrote:
> > hi,everyone!
> >
> > I want to get config file in bundle's classpath,I
have tried
> > serverl kind of methods to realize this,but all no effect.
> > This is the method list I used:
> > 1. context.getBundle().getClass().getClassLoader().getResource("config.file")
> > this method return null;
> > 2. context.getBundle().getResource("config.file")
> > this method return string
like this
> > "bundleresource://1/resource/config.file",the string
is useless to
> > execute IO;
> >
> > Can somebody tell me how to get the absolutePath
of files in
> > bundle's classpath,such as config.file?
> >
> > --
> > =============================
> > | MSN:BlueDavy@hotmail.com |
> > =============================
> >
> > _______________________________________________
> > equinox-dev mailing list
> > equinox-dev@xxxxxxxxxxx
> > https://dev.eclipse.org/mailman/listinfo/equinox-dev
> >
> >
> >
> _______________________________________________
> equinox-dev mailing list
> equinox-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/equinox-dev
>
--
=============================
| www.blogjava.net/bluedavy
|
=============================
_______________________________________________
equinox-dev mailing list
equinox-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/equinox-dev
_______________________________________________
equinox-dev mailing list
equinox-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/equinox-dev