Answers for "java how to get extension of a file"

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 how to get extension of a file"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language