title: How can I get path of resource under WEB-INF/class folder (java ee web dynamic project)
body: <p>I develop web dynamic project in Eclipse. One file, file named 'users.txt' is located under classes folder (WEB-INF/classes/users.txt).</p>
  
  <p>How I can get relative path of this file in class (base class, not servlet class)? I will use that path for append several lines of text.</p>
  
  <p>Christian this is the code that works for reading. Problem is I don't know how to create object for writing (output) in the same file with relative path.</p>
  
  <pre><code>public Products(){
      try{
          InputStream in = getClass().getClassLoader().getResourceAsStream("products.txt");    
          BufferedReader br = new BufferedReader(new InputStreamReader(in));
  
          readProducts(br);
          in.close();
              br.close();
  
  
      }catch(Exception e){
          System.out.println("File doesn't exists");
      }
      }
  
      public void readProducts(BufferedReader in) throws NumberFormatException, IOException{
  
          String id="";
          String name="";
          double price=0;
  
          StringTokenizer st;
          String line;
  
          while((line=in.readLine())!=null){
              st=new StringTokenizer(line,";");
              while(st.hasMoreTokens()){
                  id=st.nextToken();
                  name=st.nextToken();
                  price=Double.parseDouble(st.nextToken());           
              }           
              products.put(id,new Product(id,name,price));
          }
      }
  </code></pre>