What is the difference about two getResourceAsStream()?

I found a strange thing about getResourceAsStream(). This is my code:
package pkg;
class Test1 {
private static final String absName = "/WEB-INF/database.properties";
public static void main( String[] args ) throws Exception {
ClassLoader loader = testClassLoader.class.getClassLoader();
System.out.println( "classloader: " + loader );
System.out.println( loader.getResourceAsStream( absName ) );
Class c = Class.forName( "pkg.Test1" );
System.out.println( "classloader : " + c.getClassLoader() );
System.out.println( c.getResourceAsStream( absName ) );
The output is:
classloader: sun.misc.Launcher$AppClassLoader@7d8483
null
classloader : sun.misc.Launcher$AppClassLoader@7d8483
java.io.BufferedInputStream@129206
But after I remove the first slash "/", absName = "WEB-INF/database.properties";
The output is:
classloader: sun.misc.Launcher$AppClassLoader@7d8483
java.io.BufferedInputStream@3169f8
classloader : sun.misc.Launcher$AppClassLoader@7d8483
null
I am confused with the results. Anyone help? Thanks in advance.
Paula

Just in case no one has answered this question for you.
The difference is with the way the file Paths are handled.
The first filepath is telling the method to start at the root level of your directory tree and look for a directory called "WEB-INF". More than likely you do not have this directory at your root level.
When you remove the leading slash, you are telling the method to search your classpaths and find a directory called "WEB-INF". This is most likely the case.

Similar Messages

  • What is the difference between two MacBook Pro 15" Retina models: ME664RU/A and ME664RS/A

    I am looking for MacBook Pro 15" with Retina display and with russian keyboard.
    In my local sellers' catalog I found two models that I need: ME664RU/A and ME664RS/A.
    So what is the difference?
    Why there are two different country codings?

    RU = Russian Federation,  RS = Serbia
    Ciao.

  • Q: What is the difference between two "Library" Folders?

    I have two Library folders on my system, one in the "System" folder, the other a stand-alone folder with an icon on it in the open HD next to the "System" folder.
    What is the difference between these two Library directories??? I have some files in each that are duplicates.
    What should actually be inside each folder? I have had many crashes and it may be due to this duplication of software files fooling the system (?).
    Please help...Thanks in Advance,
    Diane

    Actually, you have three Library folders:
    /System/Library/
    /Library/
    /Home/Library/
    There is no "duplication" of files although there are similar folders in each. Each Library folder belongs to a user hierarchy.
    /Home/Library/ folders belong to each "standard" user on the computer. Each user has a /Home/Library/ folder. Standard users can only access their Library folder and no others.
    Some users are "admin" users. Admin users can access the /Library/ folder and some user folders, but not user data.
    Last is the System Administrator. The Sys Admin can access the /System/Library/ folder and any other folder on the computer. Also sometimes referred to as the "root" user or "super user."
    WARNING: Do not mess around in these folders. The only folders in which you may have need to access are in the /Home/Library/ folder. These would include Preferences, Preference Panes, Contextual Menus, and Applications Support.
    If you are having crashing problems it could be due to any number of things. Visit The XLab FAQs and read the FAQs on troubleshooting OS X.

  • What's the differences in two kinds of update?

    Is there any difference between software update using packet data and going to nokia care?
    -------------------If this post helped you, click on accept as solution.------------------
    -----------------------------Appreciate by clicking on white star.----------------------------
    Solved!
    Go to Solution.

    it's the same update but with a small difference.
    when using your phone to download the update from the device update menu, f.o.t.a (firmware over the air), it downloads only the files that must be updated.
    when using the software updater from your pc, it downloads not only the necessary files, but everything. thats why the update file is so big.
    it's the same thing.
    Greece Nokia X6 RM-559 v40.0.002

  • Two fields about material in AFKO: PLNBEZ and STLBEZ,what's the difference?

    Two fields about material in AFKO: PLNBEZ and STLBEZ,what's the difference?
    correct answers will be rewarded.
    thanks in advance

    Hi,
    First of all AFKO is table for Production Order Master Data. So it covers all data related BOM , Routing etc. So In order to distinguish material field related to BOM & Routing  these two different fields are there in AFKO table.
    PLNBEZ is the field for material assigned to routing operation
    STLBEZ is the field for material which is part of BOM
    Hope this clears your doubt.
    Regards,
    Tejas
    Edited by: Tejas  Pujara on Oct 8, 2008 8:22 AM

  • What's the difference between these two backup systems?

    When I bought my Macbook Pro I bought a Seagate external HD that used Bounceback Express as its backup application. But now my Mac defaults to Time Machine. What's the difference between the two applications? When I use Time Machine to back up my hard drive to the Seagate external, is it doing the same thing as Bounceback Express used to?

    In analog terms, to explain YCbCr use the example of the COMPONENT output from your DVD player. It use 3 separate cables (Y = Luminance = Green Cable), (Y-B = Blue Color Diff = BLUE Cable) and (Y-R = Red Color Diff = RED Cable). In the analog world, RGB is actually RGBHV (5-wire) and is adaptable to 15-pin VGA with a simple passive adapter. Many people will mistakenly refer to Analog Component video as RGB, since the cables are Red, Green and Blue.
    So, since all that mumbo jumbo means essentially the same, this appears to be the digital "equivalent" of what is known as Component Video in the Analog world... What I said about RGBHV does not apply to the 10-bit color, but thought I'd mention it anyway.
    -BChil

  • 1. What's the difference between private mode in Safari which i have to turn on every time again when opening safari. It's a two click activity which i would love to be able to set in the preference as default.

    1. What's the difference between private mode in Safari which i have to turn on every time again when opening safari.
    It's a two click activity which i would love to be able to set in the preference as default. It's tyering when have to do it everyday a few times. (Yes, i'm one of many who have the "i like safari but since the update crash everyday a few times" syndrome...
    Yes, i have updated my system.
    Yes, i have repared disk permissions with disk utility.
    Am open for any other help in both cases. Thank you upfront
    2. and the "tell websites not to track me" under Safari - Preference - Privacy.

    That box should prevent websites using trackers to log your movements on the Web to benefit advertisers. I have no idea if it does.
    Safari can keep your browsing history private. When you turn on private browsing, Safari doesn’t remember the pages you visit, your search history, or your AutoFill information, so your partner cannot see where you have been, but you must also remember to also turn off acceptance of cookies.
    In all other respects Private Browsing is not as private as you might think:
    http://www.switchingtomac.com/tutorials/how-to-make-safaris-private-browsing-fea ture-actually-private/
    http://www.insanely-great.com/news.php?id=9054
    and then Apple's own advice from here: http://www.apple.com/pro/tips/privacy_safari.html
    "Note that the Private Browsing option does not prevent Safari from collecting cookies (the preference files automatically generated by many websites). The Reset Safari option clears all cookies. If you want to delete only certain ones, choose Preferences from the Safari menu, click the Security tab, and then click Show Cookies. You can select and delete individual cookies from the list that appears. Careful, though — if you’re a frequent web user, this list can be very, very long."
    which is itself incomplete, the relevant part being 'If you want to delete only certain ones.
    To that end it is useful to have Safari Cookies installed, which is the only cookie manager available for Safari:
    http://sweetpproductions.com/safaricookies/
    which automatically deletes all cookies not marked as 'favourites' when closing Safari. It does the same for Flash Cookies, but they are subject for themselves:
    From this website:
    http://machacks.tv/2009/01/27/flushapp-flash-cookie-removal-tool-for-os-x/
    For those who do not know about Flash cookies, more properly referred to as Local Shared Objects (LSO), they operate in a similar way to regular browser cookies but are stored outside the purview of your browser, meaning you cannot delete them from within your browser, whether Safari, Firefox, Opera or any other. Typically they are issued from sites or 3rd party sites that contain Adobe Flash content. Since virtually all internet advertising is  delivered in Flash, Google/Doudleclick and all other internet advertising companies are sure to be tracking your browsing behavior with Flash cookies. These companies can see you traverse the Internet as you come upon the plethora of sites that contain their embedded advertising. Check out the Wikipedia entry here.
    In Mac OS X they are stored in the following location:
    /User’s Home Folder/Library/Preferences/Macromedia/Flash Player/#SharedObjects
    The settings for the Flash cookies are stored in:
    /User’s Home Folder/Library/Preferences/Macromedia/Flash Player/macromedia.com/support/flashplayer/sys
    In OS X Local Shared Objects, or Flash Cookies, are appended with a .sol suffix. Flush deletes all the Flash cookies (.sol) and their settings.
    Flush can be downloaded from that page.
    If you want to retain certain Flash cookies but not others, the excellent add-on for Safari called SafariCookies now includes a setting for automatically deleting flash cookies you don't want to retain, when Safari is shut down, in the same as it deals with ordinary cookies:
    http://www.sweetpproductions.com/safaricookies/index.htm
    which not only does that but much more equally useful stuff!
    This article covers the issue in more depth:
    http://www.wired.com/epicenter/2009/08/you-deleted-your-cookies-think-again/
    Flash cookies are also known as 'Zombie Cookies' and are used by a number of firms, including Hulu, MTV, and Myspace. Graham Cluley, senior technology consultant at the internet security firm Sophos, told BBC News that the source of the trouble was Adobe Flash itself, which he called "one of the weirdest programs on the planet".
    "I think it's highly unlikely that these large companies have abused Flash cookies - which are different from browser cookies - with malicious intent," he said.
    "I think it's much more likely that the vast majority of users are simply oblivious to the bizarre way in which Adobe allows them to configure the software."
    http://www.bbc.co.uk/news/technology-10787882
    And a more recent article:
    http://www.nytimes.com/2010/09/21/technology/21cookie.html?_r=3&scp=1&sq=flash&s t=cse
    [b]Tracker cookies and the invisible web:[/b]
    – tags, web bugs, pixels and beacons that are included on web pages in order to get an idea of your online behavior.
    Ghostery tracks the trackers and gives you a roll-call of the ad networks, behavioral data providers, web publishers, and other companies interested in your activity.
    http://www.ghostery.com/about
    This provides an extension to Safari (also available for other browsers) that shows you what data tracking is active on each web page you visit, and enables you to block them.

  • What is the difference between these two reports MC.1 and MB5L

    Hi
    what is the difference between these two reports MC.1 and MB5L?
    what is the Purpose of each report?
    Material ledger is activated for this plant, we found some amount difference between these two reports, my client accounting department used to compare these two reports while year end/month end closing
    Thanks
    Raju

    MC.1 will give you the report for plant analysis as per plant .
    MB5L report will give you list of stock value as per G/L account wise.

  • I want to buy an ipad mini Wifi Cellular and use it in Central Asia,so there are two models: A1454 and A1455,what is the difference?

    I want to buy an ipad mini Wifi Cellular and use it in Central Asia,so there are two models: A1454 and A1455,what is the difference?

    Either will work fine in Central Asia as loge ad the carries support GSM (almost all do).
    One of the iPads will only work with the AT&T GSM) network if you are in the USA and the Other with the Virizon network (uses CDMA, not GSM/SIM) if you are in the USA

  • Hello On the creative cloud there are two versions of the software, for example photoshop cc and photoshop DC (2014) what is the difference thank you

    hello
    On the creative cloud there are two versions of the software, for example photoshop cc
    and photoshop DC (2014)
    what is the difference
    thank you

    See Installing the 2014 Release of Creative Cloud « Julieanne Kost's Blog

  • What are the differences between this two statements???

    1.select * from counter where eboxid = (select acctid from zsyy_ocecs.cm_subs_subscriber where servnumber = ?);
    2.select b.* from zsyy_ocecs.CM_SUBS_SUBSCRIBER a,COUNTER b where a.acctid = b.eboxid and a.servnumber = ?;
    what are the differences between the 2 sql statements??
    I WILL APPRECIATE FOR YOUR ANSWERS VERY MUCH, BECAUSE I WAS PUZZLED WHEN I SAW THE EXECUTION PLANS.THANKS AGAIN. MR SHI.
    the followings are their execute plans:
    Command> select * from counter where eboxid = (select acctid from zsyy_ocecs.cm_subs_subscriber where servnumber = ?);
    Query Optimizer Plan:
    STEP: 1
    LEVEL: 2
    OPERATION: TblLkTtreeScan
    TBLNAME: ZSYY_OCECS.CM_SUBS_SUBSCRIBER
    IXNAME: IDX_SERVNUM
    INDEXED CONDITION: CM_SUBS_SUBSCRIBER.SERVNUMBER = qmark_1
    NOT INDEXED: ROWNUM < 3
    STEP: 2
    LEVEL: 2
    OPERATION: RowLkTtreeScan
    TBLNAME: COUNTER
    IXNAME: IDX_COUNTER
    INDEXED CONDITION:
    COUNTER.EBOXID = CM_SUBS_SUBSCRIBER.ACCTID
    NOT INDEXED: <NULL>
    STEP: 3
    LEVEL: 1
    OPERATION: NestedLoop
    TBLNAME: <NULL>
    IXNAME: <NULL>
    INDEXED CONDITION: <NULL>
    NOT INDEXED: <NULL>
    Command> select b.* from zsyy_ocecs.CM_SUBS_SUBSCRIBER a,COUNTER b where a.acctid = b.eboxid and a.servnumber = ?;
    Query Optimizer Plan:
    STEP: 1
    LEVEL: 2
    OPERATION: TmpTtreeScan
    TBLNAME: ZSYY_OCECS.CM_SUBS_SUBSCRIBER
    IXNAME: <NULL>
    INDEXED CONDITION: <NULL>
    NOT INDEXED: A.SERVNUMBER = qmark_1
    STEP: 2
    LEVEL: 2
    OPERATION: TblLkTtreeScan
    TBLNAME: COUNTER
    IXNAME: IDX_COUNTER
    INDEXED CONDITION: B.EBOXID
    = A.ACCTIDNOT INDEXED: <NULL>
    STEP: 3
    LEVEL: 1
    OPERATION: MergeJoin
    TBLNAME: <NULL>
    IXNAME: <NULL>
    INDEXED CONDITION: A.ACCTID = B.EBOXID
    NOT INDEXED: <NULL>
    Edited by: user9533799 on 2008-9-3 上午1:28

    If zsyy_ocecs.cm_subs_subscriber table returns one row for each servnumber, both statements would return the same data. But if there was a servnumber value on two rows, the first statement will throw an error (you a comparing a value with a set of values). You can rewrite the first query to avoid this:
    select * from counter where eboxid in (select acctid from zsyy_ocecs.cm_subs_subscriber where servnumber = ?);
    Conceptually they are different and the execution plan can't be the same.

  • What's the difference between the two Library folders?

    What's the difference between the two Library folders - the one in the users folder and the other?

    /Library contains files and settings that apply system wide to all users.
    ~/Library contains files and settings that only apply to your user account.

  • What is the difference of these two Coherence client command?

    What is the difference of these two Coherence client command? Kill and destroy
    Are they same command?
    Thank you

    Hi,
    The Kill command shuts down the current com.tangosol.net.CacheService. This does not affect other service members if they are in a cluster.
    The Destroy command will remove the NamedCache completely from the cluster, causing other cluster members to receive an IllegalStateException if they are holding on to a reference to the same cache and try to do any operation on that cache.
    you can try using this command and check.
    Thanks,
    Mitraa SP

  • What is the difference between these two charging cycles??

    Hi,
    When u check out this http://www.apple.com/batteries/
    it says something about 2 hours Fast Charge and 4 hour Trickle Charge!!
    what is the difference between both of them?
    i charged my iPhone that day for 4 hours but i didn't notice any difference and it says Full after 2 hours!!
    does it matter if it is charged through the computer or a power outlet on the wall??
    Thank you

    agent_s87 wrote:
    When u check out this http://www.apple.com/batteries/
    it says something about 2 hours Fast Charge and 4 hour Trickle Charge!!
    what is the difference between both of them?
    In total it takes 4 hours to recharge the battery. You won't really know the difference actually if you plug it in when you go to bed for 7 hours. It actually states 2 hours to fast charge and 2 hours trickle charge. If you look closely at the chart it's based on 4 hours in total.
    i charged my iPhone that day for 4 hours but i didn't notice any difference and it says Full after 2 hours!!
    does it matter if it is charged through the computer or a power outlet on the wall??
    No it doesn't matter each one. You can buy any number of wall chargers and power packs at your local store. Go to Bestbuy.com and type 'iPhone Power' for select power plugin iphones.
    - Griffin - PowerBlock Charger for Apple® iPod® and iPhone
    - Griffin - PowerBlock Universal Dual AC Charger
    - DLO - Power Pack Home and Auto Chargers for Apple® iPod® and iPhone
    - DLO - Power Bug for Apple® iPhone
    - Apple® - USB Power Adapter for Apple® iPod® and iPhone
    - Belkin - Power Central with Cable Catch for Apple® iPod® and iPhone - White
    - Incase - Power Slider Case for Apple® iPhone 3G - Black
    With the last one "Incase - Power Slider Case for Apple® iPhone 3G - Black" gives you a whole day worth of a charge on standby without having to put the phone on Airplane Mode to conserve power. I kept it on in my pocket for 12 hours and the iPhone was still active.
    Message was edited by: JoeZinVA

  • What is the difference between these two sites.

    What is the difference between (this site) Apple Support Communities and the Developer forum.
    When I search on "apple developers forum"  what is the difference between the first and the seconde hit.
    RL6001

    RL6001 wrote:
    What is the difference between (this site) Apple Support Communities and the Developer forum.
    Aside from any other benefits of the paid developer programs, the Developer forums are focused solely on developers. This forums is just one little out-of-the-way corner of a much larger, more consumer oriented discussion site. Questions asked in the Developer forums are typically more difficult and may take several days to get an answer. Questions here are more beginner-type questions and you will get an answer much more quickly. The Developer forums are mostly populated by professional developers who have a much different perspective than you get on most other public internet forums. If you don't know what I'm talking about then you probably wouldn't believe me anyway.

Maybe you are looking for

  • WebLogic Server Hang

    My WebLogic Server hang up sometime. The platform is IBM AIX, weblogic 8.1 with sp3 The following is the thread dump: NULL ------------------------------------------------------------------------ 0SECTION TITLE subcomponent dump routine NULL ========

  • OCI compliance with SSP4

    I need to know if SSP4 is OCI compliant (Open Catalog Interface) because I will need to connect to a Central Catalog from a distant entity. And, in order to connect through a direct line (leased line or Private Network), I have been told that my ePro

  • Query for Auto Calculation based on input of 2 Fields

    Hi, I would like to write a sql query to allow for auto calculation based on the Inputs of 2 other fields before Adding the Order. For example. A query on Sales Order where I have Item 040634 (Code for a Flower) and Quantity 200. I have a UDF (Bunchi

  • HT1848 transfer songs from my ipod touch to my device

    I was hoping that someone could tell me how to get songs from my itouch to itunes?  When I sync the device in question not all of my songs on my device end up on my computer.  Any help would be greatly appreciated.

  • Problem with reset button

    Hello All, I have a form which has several fields. There is a reset button at the top of the Page -1 of the form which should clear/rest  the form. But I have several checkboxes, out of which if some clicked few text fields / drop downs associated wi