Givemepass's Android 惡補筆記

如何判斷資料夾內有相同檔案

| Comments

File dir = new File(YOUR PATH);

File[] matches = dir.listFiles(new FilenameFilter(){
    public boolean accept(File dir, String name){
        return name.startsWith("a")&&name.endsWith(".png");
    }
});
for(File f : matches){
        System.out.println(f.getName());
}

這樣就可以抓出該資料夾以a開頭、png結尾的所有檔案了

Comments

comments powered by Disqus