Home » Eclipse Projects » Remote Application Platform (RAP) » File-Array from Workspace folder
File-Array from Workspace folder [message #86070] |
Mon, 05 May 2008 14:07  |
Eclipse User |
|
|
|
Hi, I have a rather strange question..
I have a folder in my workspace, which contains some images. What I need
is a File-Array for these images. Inside my RCP, the following Snippet
does what I want:
URL url = FileLocator.toFileURL(bundle.getEntry("images"));
File f = new File(url.getFile());
File[] list = f.listFiles();
This doesnt work in RAP, I expect the problem to be the File located
absolute within the Filesystem, rather as a relative path, which may be
not allowed??
Can someone give me a snippet of how this works, I spent nearly half day
to this and now itŽs enough:-)
I know how it works for a single File, but not for this use case with a
directory containing files. For sure this is easy to solve, but I really
donŽt get the 3-lines at the moment.
Thanks for your help!
|
|
| |
Re: File-Array from Workspace folder [message #86177 is a reply to message #86070] |
Tue, 06 May 2008 04:20   |
Eclipse User |
|
|
|
Originally posted by: fappel.innoopract.com
Hi,
what does bundle.getEntry( "images" ) return?
Ciao
Frank
-----Ursprüngliche Nachricht-----
Von: Martin [mailto:mdilger@splitshade.de]
Bereitgestellt: Montag, 5. Mai 2008 20:08
Bereitgestellt in: eclipse.technology.rap
Unterhaltung: File-Array from Workspace folder
Betreff: File-Array from Workspace folder
Hi, I have a rather strange question..
I have a folder in my workspace, which contains some images. What I need
is a File-Array for these images. Inside my RCP, the following Snippet
does what I want:
URL url = FileLocator.toFileURL(bundle.getEntry("images"));
File f = new File(url.getFile());
File[] list = f.listFiles();
This doesnt work in RAP, I expect the problem to be the File located
absolute within the Filesystem, rather as a relative path, which may be
not allowed??
Can someone give me a snippet of how this works, I spent nearly half day
to this and now itŽs enough:-) I know how it works for a single File,
but not for this use case with a directory containing files. For sure
this is easy to solve, but I really donŽt get the 3-lines at the moment.
Thanks for your help!
|
|
| | | |
Re: File-Array from Workspace folder [message #86546 is a reply to message #86070] |
Thu, 08 May 2008 03:46   |
Eclipse User |
|
|
|
Originally posted by: evolanakis.innoopract.com
Martin,
just a wild guess -- have you tried the class
org.eclipse.core.runtime.FileLocator in the org.eclipse.equinox.common
bundle ?
If I remember correctly, the method #toFileUrl() converts an bundle://
url to a file:// url, which can then be used with a File object. I've
used that in the past.
Alternatively, maybe #findEntries(...) is helpful, but I'm not too sure.
Let me know if this helped.
Regards,
Elias.
Martin wrote:
> Hi, I have a rather strange question..
> I have a folder in my workspace, which contains some images. What I need
> is a File-Array for these images. Inside my RCP, the following Snippet
> does what I want:
> URL url = FileLocator.toFileURL(bundle.getEntry("images"));
> File f = new File(url.getFile());
> File[] list = f.listFiles();
>
> This doesnt work in RAP, I expect the problem to be the File located
> absolute within the Filesystem, rather as a relative path, which may be
> not allowed??
> Can someone give me a snippet of how this works, I spent nearly half day
> to this and now itŽs enough:-)
> I know how it works for a single File, but not for this use case with a
> directory containing files. For sure this is easy to solve, but I really
> donŽt get the 3-lines at the moment.
>
> Thanks for your help!
>
|
|
|
Re: File-Array from Workspace folder [message #86560 is a reply to message #86546] |
Thu, 08 May 2008 03:47   |
Eclipse User |
|
|
|
Originally posted by: evolanakis.innoopract.com
Oops, sorry - I see you are already using file locator...
Elias.
Elias Volanakis wrote:
> Martin,
>
> just a wild guess -- have you tried the class
> org.eclipse.core.runtime.FileLocator in the org.eclipse.equinox.common
> bundle ?
>
> If I remember correctly, the method #toFileUrl() converts an bundle://
> url to a file:// url, which can then be used with a File object. I've
> used that in the past.
>
> Alternatively, maybe #findEntries(...) is helpful, but I'm not too sure.
>
> Let me know if this helped.
>
> Regards,
> Elias.
>
>
> Martin wrote:
>> Hi, I have a rather strange question..
>> I have a folder in my workspace, which contains some images. What I
>> need is a File-Array for these images. Inside my RCP, the following
>> Snippet does what I want:
>> URL url = FileLocator.toFileURL(bundle.getEntry("images"));
>> File f = new File(url.getFile());
>> File[] list = f.listFiles();
>>
>> This doesnt work in RAP, I expect the problem to be the File located
>> absolute within the Filesystem, rather as a relative path, which may
>> be not allowed??
>> Can someone give me a snippet of how this works, I spent nearly half
>> day to this and now itŽs enough:-)
>> I know how it works for a single File, but not for this use case with
>> a directory containing files. For sure this is easy to solve, but I
>> really donŽt get the 3-lines at the moment.
>>
>> Thanks for your help!
>>
|
|
| |
Re: File-Array from Workspace folder [message #86603 is a reply to message #86468] |
Thu, 08 May 2008 05:48  |
Eclipse User |
|
|
|
Originally posted by: fappel.innoopract.com
Hi,
I'm not sure what you're really intend to do. But if you want to load a
image from the bundle you may try
AbstractUIPlugin#imageDescriptorFromPlugin(String,String).
Opening an inputstream on a folder fails of course. But you can retrieve
the file handle to the folder from the URL and retrieve the children
from it. Each child that is not a directory can then be opened using a
FileInputStream.
Ciao
Frank
-----Ursprüngliche Nachricht-----
Von: Martin [mailto:mdilger@splitshade.de]
Bereitgestellt: Mittwoch, 7. Mai 2008 20:36
Bereitgestellt in: eclipse.technology.rap
Unterhaltung: File-Array from Workspace folder
Betreff: Re: File-Array from Workspace folder
Hi,
IŽm quite sure there is a bug somewhere, the following snippet works:
Image im = Graphics.getImage("someNameForMyFile", new
FileInputStream(myFile));
Using Graphics.getImage(myFile) does not work and I get a "Invalid
Image..." Exception. The File definitely exists and is on the classpath.
In my opinion both cases should work.
|
|
|
Goto Forum:
Current Time: Sat Aug 30 13:22:51 EDT 2025
Powered by FUDForum. Page generated in 0.04090 seconds
|