发发试试
public class DirTools
{
public static String getExtensionName(String filename)
{
if ((filename != null) && (filename.length() > 0))
{
int dot = filename.lastIndexOf('.');
if ((dot >-1) && (dot < (filename.length() - 1)))
{
return filename.substring(dot + 1);
}
}
return filename;
}
public static void main(String[] args)
{
String a=getExtensionName("hello.txt");
System.out.print(a);
}
}
------解决方案--------------------
发错版了吧