Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Copy files out of Plugins programmatically
Copy files out of Plugins programmatically [message #319540] Fri, 24 August 2007 09:26 Go to next message
Eclipse UserFriend
Originally posted by: stefan.bley.dd.gmx.de

Hello.
I try to copy files out of plugin bundles, but I don't come to a solution.

I get the Bundle:
Bundle b = Platform.getBundle(...);

Then I tried:
URL url = b.getResource("lib/aFile.jar"); // where lib/aFile.jar is the
file I want to copy

But what can I do with this URL? I cannot instantiate a java.io.File with
it. Is there any convenience class I did not see yet? How can I copy the
file?

Thanks in advance,
Stefan
Re: Copy files out of Plugins programmatically [message #319541 is a reply to message #319540] Fri, 24 August 2007 09:45 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dmsubs.NOSPAM.consertum.com

Look at FileLocator class.

--
Derek


Stefan Bley wrote:
> Hello.
> I try to copy files out of plugin bundles, but I don't come to a solution.
>
> I get the Bundle:
> Bundle b = Platform.getBundle(...);
>
> Then I tried:
> URL url = b.getResource("lib/aFile.jar"); // where lib/aFile.jar is the
> file I want to copy
>
> But what can I do with this URL? I cannot instantiate a java.io.File
> with it. Is there any convenience class I did not see yet? How can I
> copy the file?
>
> Thanks in advance,
> Stefan
>
Re: Copy files out of Plugins programmatically [message #319544 is a reply to message #319541] Fri, 24 August 2007 10:05 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Derek,

Yes, one could use toFileURI. That creates a copy in the file system,
so is not really the most efficient way. I'm not sure why Stefan
doesn't just use openStream on the URL to read directly from the jar and
then write those bytes to the target...


Derek Morris wrote:
> Look at FileLocator class.
>
Re: Copy files out of Plugins programmatically [message #319545 is a reply to message #319540] Fri, 24 August 2007 10:13 Go to previous message
Eclipse UserFriend
Originally posted by: automatic.javalobby.org

Get the contents as a stream, create a new file output stream, write contents of input stream to output stream. Java 101.

If you've not done stuff with IO before, check out the Java tutorial on same:

http://java.sun.com/docs/books/tutorial/essential/io/buffers .html

Basically, use that example except instead of creating a FileInputStream, you use b.getResource().openStream() instead.

Alex.
Previous Topic:Meaning of //$NON-NLS-1$
Next Topic:Accessing views of other plug-ins
Goto Forum:
  


Current Time: Wed Apr 24 13:51:12 GMT 2024

Powered by FUDForum. Page generated in 0.02759 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top