Java tutorial
//package com.java2s; import java.io.File; import java.io.FilenameFilter; public class Main { private static File getCachImage(final String id, File cachDir) { File[] list = cachDir.listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String filename) { return filename.contains(id); } }); if (list != null && list.length != 0) { return list[0]; } else { return null; } } }