(Without including any external libraries.)
What\'s the most efficient way to remove the extension of a filename in Java, without assuming anything of the f
The remove() function above should be rewritten to support test cases like LOST.DIR/myfile.txt
public static String removeExtension( String in )
{
int p = in.lastIndexOf(".");
if ( p < 0 )
return in;
int d = in.lastIndexOf( File.separator );
if ( d < 0 && p == 0 )
return in;
if ( d >= 0 && d > p )
return in;
return in.substring( 0, p );
}