FilenameFilter的使用
生活随笔
收集整理的這篇文章主要介紹了
FilenameFilter的使用
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
使用FilenameFilter過濾掉chapter開頭的文件。
1 public class contentFilter implements FilenameFilter { 2 public boolean isContent(String file) { 3 if (file.startsWith("chapter")){ 4 return false; 5 }else{ 6 return true; 7 } 8 } 9 public boolean accept(File dir, String name) { 10 return isContent(name); 11 } 12 }
1 public class Test { 2 public static void main(String[] args) { 3 File dir = new File("C://00006"); 4 String[] f = dir.list(new contentFilter()); 5 Arrays.sort(f); 6 System.out.println(f[f.length-1]); 7 } 8 }
圖片過濾:http://jimb.iteye.com/blog/124930#bc2309281
轉載于:https://www.cnblogs.com/wentao365/p/3465272.html
總結
以上是生活随笔為你收集整理的FilenameFilter的使用的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 100甩物成功采纳
- 下一篇: ASP.NET Web API自身对CO