Add getExtension method with String parameter.
This commit is contained in:
parent
df3a0350af
commit
8ecd4c57cd
1 changed files with 27 additions and 2 deletions
|
@ -114,10 +114,35 @@ public class FileTools
|
|||
}
|
||||
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)
|
||||
{
|
||||
result = file.getName().substring(separatorIndex + 1).toLowerCase();
|
||||
result = fileName.substring(separatorIndex + 1).toLowerCase();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue