//if you have the path
String someFilepath = "image.fromyesterday.test.jpg";
String extension = someFilepath.substring(someFilepath.lastIndexOf("."));
//direct with file
String extension = ff.getAbsolutePath().substring(ff.getAbsolutePath().lastIndexOf("."));