1. 程式人生 > >相對路徑轉成絕對路徑

相對路徑轉成絕對路徑

	public static String getAbsoluteURL(String baseURI, String relativePath) {
		String abURL = null;
		try {
			URI base = new URI(baseURI);// 基本網頁URI
			URI abs = base.resolve(relativePath);// 解析於上述網頁的相對URL,得到絕對URI
			URL absURL = abs.toURL();// 轉成URL
			abURL = absURL.toString();
		} catch (MalformedURLException e) {
			e.printStackTrace();
		} catch (URISyntaxException e) {
			e.printStackTrace();
		} finally {
			return abURL;
		}
	}