Opening a file from a JarFileSystem

I am trying to get the contents of a file in a jar file. I find the correct file system by using the following code:


Or am I going about this all wrong?

Thanks

Todd Breiholz

2 comments

So what is 'realPath'? Is it path to some jar (that is something like
'c:\Bla\Bla\somejar.jar')? Is it path obtained from some java.io.File (that
is path in terms of native file system)?
And which file you need to find in a jar? Do you know its path inside jar?

--
Valentin Kipiatkov
JetBrains, Inc
http://www.intellij.com
"Develop with pleasure!"



"Todd Breiholz" <no_mail@jetbrains.com> wrote in message
news:16358262.1070443068296.JavaMail.javamailuser@localhost...

I am trying to get the contents of a file in a jar file. I find the

correct file system by using the following code:
>

                 VirtualFileManager vfm = VirtualFileManager.getInstance();
>                 VirtualFileSystem[] fileSystems = vfm.getFileSystems();
>                 for (int i = 0; i < fileSystems.length; i++) {
>                     VirtualFileSystem fileSystem = fileSystems+;
>                     if (!"dummy".equals(fileSystem.getProtocol())) {
>                         VirtualFile fileByPath =
fileSystem.findFileByPath(realPath);
>                         if (fileByPath != null) {
>                           // found the file, how do I get the contents???
>                         }
>                      }
>                   }
>
> ]]>

>

Or am I going about this all wrong?

>

Thanks

>

Todd Breiholz



0

Try the attached plugin. Its not complete yet. Its an editor for Jar
files and shows you the content. The opening of the files directly out
of the jar is not done yet.

Sven

Todd Breiholz wrote:

I am trying to get the contents of a file in a jar file. I find the correct file system by using the following code:

                 VirtualFileManager vfm = VirtualFileManager.getInstance();
>                 VirtualFileSystem[] fileSystems = vfm.getFileSystems();
>                 for (int i = 0; i < fileSystems.length; i++) {
>                     VirtualFileSystem fileSystem = fileSystems+;
>                     if (!"dummy".equals(fileSystem.getProtocol())) {
>                         VirtualFile fileByPath = fileSystem.findFileByPath(realPath);
>                         if (fileByPath != null) {
>                           // found the file, how do I get the contents???
>                         }
>                      }
>                   }
> 
> ]]>


Or am I going about this all wrong?

Thanks

Todd Breiholz




Attachment(s):
previewPlugin.jar
0

Please sign in to leave a comment.