How to open your file extension in Java code example
Example: java how to read file extension
private static String getFileExtension(File file) {
String extension = "";
try {
if (file != null && file.exists()) {
String name = file.getName();
extension = name.substring(name.lastIndexOf("."));
}
} catch (Exception e) {
extension = "";
}
return extension;
}