Answers for "get extension from 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 "get extension from file"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language