CORE
HOME > JAVA > J2SE > CORE
2015.06.19 / 10:19

µð·ºÅ丮¾ÈÀÇ ÆÄÀÏ ¸ñ·Ï ¸ðµÎ °¡Á®¿À±â (ÇÏÀ§ µð·ºÅ丮 ±îÁö Æ÷ÇÔ)

¸ÞÀÏ·¯
Ãßõ ¼ö 178

Ãâó´Â http://blog.naver.com/junprio79

 

 

public ArrayList<String> listInDir(String path, String extention) {
    File dir = new File(path);
    if (!dir.isDirectory()) {
        return null;
    }
    File[] allList = dir.listFiles();
    ArrayList<String> list = new ArrayList<String>();
    String name = null;
    String ext = null;
    int extLength = extention.length();
    for (int i = 0; i < allList.length; i++) {
        if (allList[i].isDirectory()) {
            list.addAll(empPhotoListInDirectory(allList[i].getPath(), extention));
        }
        name = allList[i].getName();
        if (name.length() <= extLength) {
            continue;
        }
        ext = name.substring(name.length() - extLength, name.length());
        if (ext.equalsIgnoreCase(extention) || extention == "*") {
            list.add(allList[i].getPath());
        }
    }
    return list;
}