src/main/java/org/openjfx/core/ImageUtil.java
public static List<File> filterValidImageFiles(List<File> files) {

        return files.stream().filter(file -> {

            try {
                String mimetype = Files.probeContentType(file.toPath());

                if (mimetype != null && mimetype.split("/")[0].equals("image")) {
                    return true;
                }
                return false;
            } catch (Exception e) {
                return false;
            }

        }).collect(Collectors.toList());

    }
/**
     * Check image file MIME type before show it into gridPane
     *
     * - Files with .jpg, .png extension names are not necessary images. So the file picker would not be sufficient
     * - MIME check is necessary.
     *
     * @param files
     * @return
     */
Check image file MIME type before show it into gridPane
- Files with .jpg, .png extension names are not necessary images. So the file picker would not be sufficient
- MIME check is necessary.

@param files
@return
Check image file MIME type before show it into gridPane - Files with . jpg . png extension names are not necessary images . So the file picker would not be sufficient - MIME check is necessary . @param files @return
public static List<File> filterValidImageFiles(List<File> files) {
        return files.stream().filter(file -> {
            try {
                String mimetype = Files.probeContentType(file.toPath());
                if (mimetype != null && mimetype.split("/")[0].equals("image")) {
                    return true;
                }
                return false;
            } catch (Exception e) {
                return false;
            }
        }).collect(Collectors.toList());
    }
public static List < File > filterValidImageFiles ( List < File > files ) { return files . stream ( ) . filter ( file -> { try { String mimetype = Files . probeContentType ( file . toPath ( ) ) ; if ( mimetype != null && mimetype . split ( "/" ) [ 0 ] . equals ( "image" ) ) { return true ; } return false ; } catch ( Exception e ) { return false ; } } ) . collect ( Collectors . toList ( ) ) ; }
Check image file MIME type before show it into gridPane
 - Files with .jpg, .png extension names are not necessary images.
Check image file MIME type before show it into gridPane - Files with . jpg . png extension names are not necessary images .