Java File Name Extract extractFileNameFromUrl(String url)

Here you can find the source of extractFileNameFromUrl(String url)

Description

extract File Name From Url

License

Open Source License

Declaration

public static String extractFileNameFromUrl(String url) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static String extractFileNameFromUrl(String url) {
        String newFileName = "";
        String tempStr = "";

        int counter = url.length() - 1;
        char ch = url.charAt(counter);
        while (ch != '/') {
            tempStr += ch;/*from  w  w w.j  a  va  2 s  .  c om*/
            ch = url.charAt(counter);
            counter--;
        }

        for (int i = tempStr.length() - 1; i >= 0; i--) {
            newFileName += tempStr.charAt(i);
        }

        return newFileName;
    }
}

Related

  1. extractFileNameFromContentDisposition(String contentDisposition)
  2. extractFileNameFromPath(final String filePath, char separatorChar)
  3. extractFileNameFromPath(final String path)
  4. extractFilenameFromPath(String path)
  5. extractFilenameFromURL(String url)
  6. extractFilenameFromUrlPath(String urlPath)
  7. extractFileNames(String[] fileNames)