https://issues.apache.org/ooo/show_bug.cgi?id=120273
--- Comment #9 from ChaoHuang <[email protected]> --- > > Another simple way to convert path to url : > File aFile = new File("d:/convert/h%e%l%l%o.odt"); > String aUrl = aFile.toURI().toString(); > > The result is "file:/D:/convert/h%25e%25l%25l%25o.odt", which is close to > the target. But need to add two slashes ("//") after "file:/" . public static String ConvertFileName2Url(String strFileName) { String strUrl = "file://"; try { File aFile = new File(strFileName); strUrl += aFile.toURI().getRawPath(); } catch (Exception e) { e.printStackTrace(); } finally { return strUrl; } } Usage : String strUrl = ConvertFileName2Url(strFileName); -- You are receiving this mail because: You are the assignee for the bug.
