Java URL Value Check isFileSpecified(URL url)

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

Description

Determines whether a file is specified in the path part of the url.

License

LGPL

Parameter

Parameter Description
url the url to test

Return

boolean value indicating whether a file is specified

Declaration

public static boolean isFileSpecified(URL url) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

import java.net.URL;

public class Main {
    /**/*w  w w  .  j a va2  s .  co  m*/
     * Determines whether a file is specified in the path part of the url.
     * This is assumed to be the case if the string after the last slash
     * contains a dot (aaaaa/bbbb/cccc.dddd).
     * @param url the url to test
     * @return boolean value indicating whether a file is specified
     */
    public static boolean isFileSpecified(URL url) {
        boolean specified = false;

        String path = url.getPath();
        int posLastSlash = path.lastIndexOf('/');
        int posLastDot = path.lastIndexOf('.');

        specified = posLastDot > posLastSlash;

        return specified;
    }
}

Related

  1. isFile(final URL url)
  2. isFile(URL url)
  3. isFile(URL url)
  4. isFileInJar(URL resource)
  5. isFileResource(URL resource)
  6. isFileURL(String path)
  7. isFileURL(URL repositoryURL)
  8. isFileURL(URL url)
  9. isFileURL(URL url)