// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import java.io.File;

public class WhatDir {
    public static void main(String[] args) throws Exception {
        String relfnm = "../subdir/filename.txt";
        String p1 = new File(relfnm).getAbsolutePath();
        System.out.println(p1);
        String p2 = new File(relfnm).getCanonicalPath();
        System.out.println(p2);
        String p3 = new File(WhatDir.class.getProtectionDomain().getCodeSource().getLocation().getPath() + relfnm).getAbsolutePath();
        System.out.println(p3);
        String p4 = new File(WhatDir.class.getProtectionDomain().getCodeSource().getLocation().getPath() + relfnm).getCanonicalPath();
        System.out.println(p4);
    }
}
