Quantcast
Channel: Developer Feed - Snippet
Viewing all articles
Browse latest Browse all 178

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

$
0
0

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();

read more


Viewing all articles
Browse latest Browse all 178

Trending Articles