Add getExtension method with String parameter.

This commit is contained in:
Christian P. MOMON 2013-10-29 15:17:20 +01:00
parent df3a0350af
commit 8ecd4c57cd

View file

@ -114,10 +114,35 @@ public class FileTools
} }
else else
{ {
int separatorIndex = file.getName().lastIndexOf('.'); result = getExtension(file.getName());
}
//
return result;
}
/**
* Get the extension of a file.
*
* @param file
* Source.
*
* @return Extension value or null.
*/
public static String getExtension(final String fileName)
{
String result;
if (fileName == null)
{
result = null;
}
else
{
int separatorIndex = fileName.lastIndexOf('.');
if (separatorIndex > 0) if (separatorIndex > 0)
{ {
result = file.getName().substring(separatorIndex + 1).toLowerCase(); result = fileName.substring(separatorIndex + 1).toLowerCase();
} }
else else
{ {