title: Getting the absolute Path of a hidden folder in Java
body: <p>I'm new to java and yes I tried to search here and with google. I'm afraid with the wrong keywords :( Sorry! </p>
  
  <p>I want to get the path of a hidden directory without the filename on my Mac. Finaly it should also run on a Linux System. My code works fine for non-hidden directorys.   </p>
  
  <p>I tried the following code: </p>
  
  <pre><code>package test;
  
  import java.io.File; 
  import java.io.IOException;
  import java.security.NoSuchAlgorithmException;
  
  public class test {
   public static void main(String[] args) throws Exception {
      try {
          File Path = new File("./.AAA");
          File[] files = Path.listFiles();
  
          for (File file : files) {
              if (file.isDirectory()) {
                  // crawlPath(file);
              } else {
                  String absolutePath = file.getAbsolutePath();
                  String filePath = absolutePath.substring(0,absolutePath.lastIndexOf(File.separator)); // )-1);
  
                  System.out.println("*File path:\t\t" + filePath);
                  System.out.println("*getParentFile\t\tfile:" + file.getParentFile());
                  System.out.println("*getParent()\t\tfile:" + file.getParent());
                  System.out.println("*getAbsolutePath()\tfile:" + file.getAbsolutePath());
                  System.out.println("*getAbsoluteFile()\tfile:" + file.getAbsoluteFile());
                  System.out.println("*getPath\t\tfile:" + file.getPath());
                  System.out.println("*getName\t\tfile:" + file.getName());
                  System.out.println("*getCannonicalPath\tfile:" + file.getCanonicalPath());
                  System.out.println("*getCannonicalFile\tfile:" + file.getCanonicalFile());
              }
          }
      } catch (IOException e) {
          System.err.println("xx: " + e.getClass().getName() + ": " + e.getMessage());
          e.printStackTrace();
      }
   }
  }
  </code></pre>
  
  <p>What I`m get from the code above: </p>
  
  <pre><code>*File path:     /Users/chris/Desktop/Projekte/Projekte.myIT/Projekt.Datenwust/test/./.AAA
  *getParentFile      file:./.AAA
  *getParent()        file:./.AAA
  *getAbsolutePath()  file:/Users/chris/Desktop/Projekte/Projekte.myIT/Projekt.Datenwust/test/./.AAA/test
  *getAbsoluteFile()  file:/Users/chris/Desktop/Projekte/Projekte.myIT/Projekt.Datenwust/test/./.AAA/test
  *getPath        file:./.AAA/test
  *getName        file:test
  *getCannonicalPath  file:/Users/chris/Desktop/Projekte/Projekte.myIT/Projekt.Datenwust/test/.AAA/test
  *getCannonicalFile  file:/Users/chris/Desktop/Projekte/Projekte.myIT/Projekt.Datenwust/test/.AAA/test
  </code></pre>
  
  <p>In the first line I expect *File path: /Users/chris/Desktop/Projekte/Projekte.myIT/Projekt.Datenwust/test/.AAA instead of ...test/./.AAA at the end. </p>
  
  <p>In the last line with the filename in the path I get the expected .../test/.AAA/test </p>
  
  <p>My question is now: What are the Problem with the hidden .Folders? How do I get the "./" chars out of the path? </p>
  
  <p>Thank you very much!</p>