Java Path File Name nio getAbsolutePathName(File dir)

Here you can find the source of getAbsolutePathName(File dir)

Description

get Absolute Path Name

License

LGPL

Declaration

public static String getAbsolutePathName(File dir) 

Method Source Code


//package com.java2s;
//License from project: LGPL 

import java.io.File;
import java.io.IOException;
import java.nio.file.LinkOption;
import java.nio.file.Path;
import java.nio.file.Paths;

public class Main {
    public static String getAbsolutePathName(File dir) {
        try {/*from   w ww.  j av  a2 s.c  o m*/
            return getAbsolutePath(dir).toString();
        } catch (IOException e) {
            return dir.getAbsolutePath();
        }
    }

    public static Path getAbsolutePath(File dir) throws IOException {
        return Paths.get(dir.getPath()).toRealPath(LinkOption.NOFOLLOW_LINKS);
    }
}

Related

  1. findRootPathForResource(String resourceName, ClassLoader classLoader)
  2. findUpward(String filename, Path startingPath)
  3. formatPathName(Path path)
  4. getAbsolutePath(String fileName)
  5. getAbsolutePath(String name)
  6. getAllFiles(List fileNames, Path path)
  7. getArtifactName(Path artifactPath)
  8. getBandNameStr(Path filePath)
  9. getClassName(Path pluginImplementationDirectory, Path classFile)