class Util {

    public static String expandUserHome(String text) {
        if (text.equals("~"))
            return getUserHome();
        if (text.indexOf("~/") == 0 || text.indexOf("file:~/") == 0 || text.indexOf("jar:file:~/") == 0)
            return text.replaceFirst("~/", Matcher.quoteReplacement(getUserHome()) + "/");
        if (text.indexOf("~\\") == 0 || text.indexOf("file:~\\") == 0 || text.indexOf("jar:file:~\\") == 0)
            return text.replaceFirst("~\\\\", Matcher.quoteReplacement(getUserHome()) + "\\\\");
        return text;
    }

    private  Util();

}