com.googlecode.download.maven.plugin.internal.FileNameUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of download-maven-plugin Show documentation
Show all versions of download-maven-plugin Show documentation
This is a plugin meant to help maven user to download
different files on different protocol in part of maven build. For the
first implementation, there will only be a goal that will help
downloading a maven artifact from the command line. Future version of
the plugin could include web download, ftp download, scp download and
so on.
The newest version!
package com.googlecode.download.maven.plugin.internal;
import java.net.URI;
/**
* Common utilities used by the {@link WGetMojo}
*/
public final class FileNameUtils {
/**
* Attempts to construct the target file name based on an URI as the relative resource name
* or, if the root resource is requested, the host name extracted from the URI.
* @param uri uri to extract the output name from
* @return output file name based on the URI
*/
public static String getOutputFileName(URI uri) {
return uri.getPath().isEmpty() || uri.getPath().equals("/")
? uri.getHost()
: uri.getPath().substring(uri.getPath().lastIndexOf('/') + 1);
}
}