Switch to full style
Java2 codes,problems ,discussions and solutions are here
Post a reply

compute number of files in directory

Wed Feb 25, 2009 3:31 pm

please , anyone help me in java program that can compute number of files
and get its name on my pc



Re: compute number of files in directory

Fri May 31, 2013 1:12 pm

Code:

String files
;
  
File myFolder= new File(path);
  
File[] listOfFiles myFolder.listFiles(); 
 
  for (
int i 0listOfFiles.lengthi++) 
  {
 
   if (
listOfFiles[i].isFile()) 
   {
   
files listOfFiles[i].getName();
   
System.out.println(files);
      }
  }  
 

listOfFiles.length is the directory number of files!

Post a reply
  Related Posts  to : compute number of files in directory
 count the number of files in directory & its sub directories     -  
 Print all files in a directory     -  
 show all files in a directory with detail     -  
 convert integer number to octal,hexadecimal number systems     -  
 convert octal number to decimal number     -  
 convert decimal number to octal number     -  
 compute binomial coefficients     -  
 compute area of the circle.     -  
 loop to compute the tuition in ten years     -  
 Program to compute commission using two methods     -  

Topic Tags

Java Files and I/O