Answers for "java flile ext"

3

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;
 
    }
Posted by: Guest on March-15-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language