title: how to locate a file?
body: <p>Hi I want to know how the program can locate a file.
  For example. I have a class</p>
  
  <pre><code>    public class MiReader {
  
      private File file;    
      private BufferedReader bufferedReader;    
  
      public MiReader(String dir) {
  
          try {
              file= new File(dir);
              bufferedReader = new BufferedReader(new FileReader(file));
  
          } catch (Exception ex) {
              Logger.getLogger(MiReader.class.getName()).log(Level.SEVERE, null, ex);
          }        
      }
  
      public void imprimir() {    
          ***
      }
  }
  </code></pre>
  
  <p>I know that the file is on the project (I'm using netbeans)
  project is on <code>C:\NetBeansProjects\Application</code></p>
  
  <p>file: <code>C:\NetBeansProjects\Application\file.txt</code></p>
  
  <p>so when I instance MiReader must be something like this:</p>
  
  <pre><code>MiReader mr = new MiReader("C:\\NetBeansProjects\\Application\\file.txt");
  </code></pre>
  
  <p>and now if I run the program from another location
  for example now its on </p>
  
  <p><code>D:\Pograms\Application</code></p>
  
  <p>so the file is <code>D:\Pograms\Application\file.txt</code></p>
  
  <p>and now I have to change the way I create the class to</p>
  
  <pre><code>MiReader mr = new MiReader("D:\\Pograms\\Application\\file.txt");
  </code></pre>
  
  <p>I want to know how the program can locate the file just running the program,
  something like </p>
  
  <pre><code>MiReader mr = new MiReader(program.getLocation()+"\\file.txt")
  </code></pre>
  
  <blockquote>
    <p>Learning english :)</p>
  </blockquote>