Finding files with .java extension in specified folder -


task :

write java application accepts 2 file names arguments: dirname , filename find non-directory files contained in directory dirname name ends in ".java"

i tried use code how can print out files ending ".java" ? it's first time work things , don't know how use them.

import java.io.file; import java.io.filenamefilter;  public class filter {      public static file[] finder(string dirname){         file dir = new file(dirname);          return dir.listfiles(new filenamefilter() {                   public boolean accept(file dir, string filename)                       { return filename.endswith(".txt"); }         });      }      public static void main(string[] args){         string dirname = "src";         system.out.println(finder(dirname));      }  } 

return !dir.isdirectory() && filename.endswith(".java"); 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -