Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / January 2007

Tip: Looking for answers? Try searching our database.

Please help me understand Class.getResourceAsStream()

Thread view: 
www - 26 Jan 2007 16:26 GMT
Hi,

My Java program needs to do a lot of reading from text files or writing
to text files. I always provide the absolute path to those files. Things
are working.

But, I have heard that Class.getResourceAsStream() can do things more
intelligent: after specifying the path, the Java will search for the
file along the path to find the file with name matches what I want. This
will be useful, since my files have unique file names.

Is my understanding correct? I don't see many people using it and few
examples out there to help me start it. Could you give me some help?
Thank you.
Manish Pandit - 26 Jan 2007 19:21 GMT
> Hi,
>
[quoted text clipped - 10 lines]
> examples out there to help me start it. Could you give me some help?
> Thank you.

Yes, your understanding is correct that the vm will look for the
resource, and return you an input stream for it. However, the resource
will not be searched in $PATH if that is what you mean by "path". You
will have to ensure that the resource or the jar file containing the
resource is in the *classpath*.

-cheers,
Manish


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.