incubator-ooo-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject [Bug 120273] Can not open a file in UNO mode, if there is a "%" in file name
Date Sat, 14 Jul 2012 00:59:47 GMT
https://issues.apache.org/ooo/show_bug.cgi?id=120273

--- Comment #9 from ChaoHuang <chao.dev.h@gmail.com> ---

> 
> 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.

Mime
View raw message