Java URL to File Name URIToFilename(String str)

Here you can find the source of URIToFilename(String str)

Description

Fixes a platform dependent filename to standard URI form.

License

Open Source License

Parameter

Parameter Description
str The string to fix.

Return

Returns the fixed URI string.

Declaration

public static final String URIToFilename(String str) 

Method Source Code

//package com.java2s;

public class Main {
    /**/*from w  w  w  .j a v  a2s . c  o m*/
     * Fixes a platform dependent filename to standard URI form.
     *
     * @param str The string to fix.
     *
     * @return Returns the fixed URI string.
     */
    public static final String URIToFilename(String str) {
        // Windows fix
        if (str.length() >= 3) {
            if (str.charAt(0) == '/' && str.charAt(2) == ':') {
                char ch1 = Character.toUpperCase(str.charAt(1));
                if (ch1 >= 'A' && ch1 <= 'Z')
                    str = str.substring(1);
            }
        }
        // handle platform dependent strings
        str = str.replace('/', java.io.File.separatorChar);
        return str;
    }
}

Related

  1. getFileName2(String url)
  2. getFileNameArray(String url)
  3. getFileNameFromContentDisposition(URLConnection connection)
  4. getFileNameFromUrl(URL inputUrl)
  5. getFileNameFromUrl(URL inputUrl)