Skip to main content

[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

The real question is what do u want to do with it.

I.e.
URL url = context.getBundle().getResource("config.file");
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@xxxxxxxxxxx      |
=============================

_______________________________________________
equinox-dev mailing list
equinox-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/equinox-dev





Back to the top