Here you can find the source of isImage(String fileName, boolean output)
Parameter | Description |
---|---|
fileName | a parameter |
output | a parameter |
public static boolean isImage(String fileName, boolean output)
//package com.java2s; import javax.activation.MimetypesFileTypeMap; public class Main { /**//from w w w .j a va 2 s . com * Obtains a files MIME type and returns true if it is of type image * @param fileName * @param output * @return true if an image; false otherwise */ public static boolean isImage(String fileName, boolean output) { MimetypesFileTypeMap mimeTypesMap = new MimetypesFileTypeMap(); String mimeType = mimeTypesMap.getContentType(fileName); if (output) { System.out.println("Validating input file..."); System.out.println("File type: " + mimeType); } if (mimeType.startsWith("image")) { return true; } else { if (output) { System.out.println("Invalid file type input. Please enter an image"); } return false; } } }