URL base = new URL(baseUrl);
URL base; if (baseUrl == null || baseUrl.length() == 0) { base = new File(".").toURL(); } else { base = new URL(baseUrl); }
    public String resolveURI(String uri) {        URL ref = null;        if (uri.trim().equals("")) return baseUrl;//jar URLs don't resolve this right        if (uri.startsWith("demo:")) {            DemoMarker marker = new DemoMarker();            String short_url = uri.substring(5);            if (!short_url.startsWith("/")) {                short_url = "/" + short_url;            }            ref = marker.getClass().getResource(short_url);        } else {            try {                URL base = new URL(baseUrl);                ref = new URL(base, uri);            } catch (MalformedURLException e) {                e.printStackTrace();            }        }        if (ref == null)            return null;        else            return ref.toExternalForm();    }