title: How getClassLoader().getResourceAsStream() works in java
body: <p>I google how below code loads the resource 
      Abc.class.getClassLoader().getResourceAsStream("abc.txt")<br>
  and find that it searchs the resource in all jar file and zip file in class path.</p>
  
  <p>But when i tried it I am not able to loads it but if i give package path then I am able to loads it
  can someone tell me how getResourceAsStream search the class path</p>
  
  <p>Thanks</p>
  
  <p>one scenario is :-
  My below code is a simple program and my resource file abc.txt is inside com.abc package. when i specify path of package it worked and when i did not it does not work.</p>
  
  <pre><code>package com.abc;
  
  public class ResourceExp {
  
      public static void main(String args[])
      {
          new ResourceExp().getResource();
      }
  
      public void getResource()
      {
          String name = "abc.txt";
          // worked
          System.out.println(ResourceExp.class.getClassLoader().getResourceAsStream("com/abc/"+name));
          //not workded
          //System.out.println(ResourceExp.class.getClassLoader().getResourceAsStream(name));
  
      }
  
  }    
  </code></pre>
  
  <p>if getResourceAsStream looks the resource in all jar file and directory then why i have to specify the package path </p>