You could use String class split() function. Here you could pass a regular expression. In this case, it would be "\.". This will split the string in two parts the second part will give you the file extension.
public class Sample{
public static void main(String arg[]){
String filename= "c:\\abc.txt";
String fileArray[]=filename.split("\\.");
System.out.println(fileArray[fileArray.length-1]); //Will print the file extension
}
}