Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Main class directory



le 31/08/03 19:02, Rob Ross ` email@hidden a icrit :

> The file path and class path are two distinct concepts. Keep in mind what
> you are trying to do will fail if your classes are in a jar file; the file
> system doesn't recognize a jar as a "file system" - it's just a single file,
> so it can't look inside to find individual files.
>
> The way to do what you want is to use getResource() method of Class. Ie,
>
> URL someObject.getClass().getResource(com.myPacackageList.foo.myFile);
>
> then you can call openStream() on the URL to get an InputStream to your
> "file".
>
> Or you could also just call getResourceAsStream() of Class, and get an
> InputStream directly.
>
> But the key here is you won't be able to work with a File object, you'll
> have an InputStream, but that is something you can work with.
>
> Again, if your file is part of a jar archive, it's not accessible by any
> file-system calls.
>
> Rob
>

The file itself is not in the .jar. What I'm interested in is the path of
the .jar. I understand I can it from the URL of the resource.

Thanks,

Eric
_______________________________________________
java-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/java-dev
Be sure to read the FAQ http://developer.apple.com/java/faq/ before posting
Do not post admin requests to the list. They will be ignored.

References: 
 >RE: Main class directory (From: "Rob Ross" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.