Here you can find the source of getURI(String path, String name)
Parameter | Description |
---|---|
name | Name of file |
path | Path to file |
public static URI getURI(String path, String name) throws Exception
//package com.java2s; //License from project: Open Source License import java.net.URI; public class Main { /**// ww w .j a v a2 s.c om * Return a URI object for a filename with the given path * * @param name * Name of file * @param path * Path to file * * @return URI object for named file * * @exception dException * something went wrong creating the URI. */ public static URI getURI(String path, String name) throws Exception { URI uri; // construct a URI from a path and string try { String URIstr = path + "/" + name; // replace any spaces with %20; while (URIstr.indexOf(' ') > 0) { int spcLoc = URIstr.indexOf(' '); StringBuffer sb = new StringBuffer(URIstr); sb.replace(spcLoc, spcLoc + 1, "%20"); URIstr = new String(sb); } uri = new URI(URIstr); } catch (Exception ex) { System.out.println("malformed URI"); ex.printStackTrace(); throw ex; } return uri; } }