/** * Gets the absolute path. * * @return the absolute path */ public String getAbsolutePath() { if (getFile() != null) { try { return XML.forwardSlash(getFile().getCanonicalPath()); } catch (IOException ex) { ex.printStackTrace(); } return getFile().getAbsolutePath(); } if (getURL() != null) { URL url = getURL(); String path = url.getPath(); // remove file protocol, if any if (path.startsWith("file:")) { // $NON-NLS-1$ path = path.substring(5); } // remove leading slash if drive is specified if (path.startsWith("/") && path.indexOf(":") > -1) { // $NON-NLS-1$ //$NON-NLS-2$ path = path.substring(1); } // replace "%20" with space int i = path.indexOf("%20"); // $NON-NLS-1$ while (i > -1) { String s = path.substring(0, i); path = s + " " + path.substring(i + 3); // $NON-NLS-1$ i = path.indexOf("%20"); // $NON-NLS-1$ } return path; } return null; }