Java URL to File Name getFileName(URL url)

Here you can find the source of getFileName(URL url)

Description

get File Name

License

Open Source License

Declaration

public static String getFileName(URL url) 

Method Source Code


//package com.java2s;
/*/*from w w w.j a  va2s . co  m*/
 * This file is part of the Jose Project
 * see http://jose-chess.sourceforge.net/
 * (c) 2002-2006 Peter Sch?fer
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 */

import java.io.*;
import java.net.URL;
import java.net.URLDecoder;

public class Main {
    public static String getFileName(URL url) {
        File file = getFile(url);
        return file.getName();
    }

    public static File getFile(URL url) {
        return new File(getFilePath(url));
    }

    public static String getFilePath(URL url) {
        return URLDecoder.decode(url.getPath());
    }
}

Related

  1. getFileName(String urlString)
  2. getFileName(URL extUrl)
  3. getFileName(URL url)
  4. getFileName(URL url)
  5. getFileName(URL url)
  6. getFileName(URL url)
  7. getFileName(URL url)
  8. getFileName(URLConnection urlC)
  9. getFileName2(String url)