
Untitled
By: a guest on
Apr 30th, 2012 | syntax:
None | size: 0.66 KB | hits: 16 | expires: Never
Java - Find absolute path of file
PathMatcher match = FileSystems.getDefault().getPathMatcher("glob:vjlc.{exe, jpg, png}");
Path filename = FileSystems.getDefault().getPath("vjlc.exe","");
if(match.matches(filename))
{
System.out.println(filename);
}
File fil = new File("vlc.exe");
System.out.println( fil.getAbsolutePath() );
String path = System.getenv("PATH");
String pathSeparator = System.getProperty("path.separator");
for (String pathElement : path.split(pathSeparator)) {
File file = new File(pathElement, "vlc.exe");
if (file.isFile()) {
// vlc.exe exists in this location.
}
}