Add removeExtension method.

This commit is contained in:
Christian P. MOMON 2013-11-28 04:54:07 +01:00
parent 4258667c63
commit b8ed6841c8

View file

@ -400,6 +400,39 @@ public class FileTools
} }
} }
/**
*
* @param source
* @param extension
* @return
*/
public static String removeExtension(final String source)
{
String result;
if (source == null)
{
result = source;
}
else
{
int separatorIndex = source.lastIndexOf('.');
//
if (separatorIndex > 0)
{
result = source.substring(0, separatorIndex);
}
else
{
result = source;
}
}
//
return result;
}
/** /**
* *
* @param file * @param file
@ -535,5 +568,4 @@ public class FileTools
// //
return result; return result;
} }
} }