Quantcast
Viewing all articles
Browse latest Browse all 29

How to check if a file is an Image in Android using FileFilters?

In order to check if file is an Image, one can check for the file extension (jpg, png, etc.) using FileFilter as shown below:

  1. packagecom.livrona.apps.sikh.wallpapers;
  2.  
  3. importjava.io.File;
  4. importjava.io.FileFilter;
  5.  
  6.  
  7. // TODO: Auto-generated Javadoc
  8. /**
  9.  * The Class CheckImageExtension.
  10.  */
  11. publicclass CheckImageExtension {
  12.  
  13.  
  14.      /** The is valid image. */
  15.      publicstaticFileFilter isValidImage =newFileFilter(){
  16.  
  17.  
  18.           @Override
  19.           publicboolean accept(File pathname){
  20.                finalString name = pathname.getName();

Viewing all articles
Browse latest Browse all 29

Trending Articles