Here you can find the source of hasJpg(String path)
public static boolean hasJpg(String path)
import java.io.BufferedReader; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.InputStreamReader; import java.nio.charset.Charset; import java.util.ArrayList; public class Main{ public static boolean hasJpg(String path) { File dir = new File(path); File[] files = dir.listFiles(); if (files == null) { return false; }//w w w . j a va 2 s . c o m for (int i = 0; i < files.length; i++) { if (files[i].isDirectory()) { return FileUtil.hasJpg(files[i].getAbsolutePath()); } else { String filename = files[i].getAbsolutePath(); String filetype = filename.substring(filename .lastIndexOf(".") + 1); if (filetype.equalsIgnoreCase("jpg") || filetype.equalsIgnoreCase("jpeg") || filetype.equalsIgnoreCase("gif") || filetype.equalsIgnoreCase("bmp") || filetype.equalsIgnoreCase("png")) { return true; } } } return false; } }