Infolinks In Text Ads

Jun 26, 2010

How to calculate no of files in a directory in java code examples

private static int calNoOfFiles(String directoryPath)
    {
        File fd = new File(directoryPath);
        if(!fd.isFile())
        {
            String list[] = fd.list();
            for(int i = 0; i < list.length; i++)
            {
                String tempDirPath = directoryPath + fileDelimiter + list[i];
                debug(tempDirPath);
                File ftd = new File(tempDirPath);
                if(ftd.isFile())
                    noOfFiles++;
                if(ftd.isDirectory())
                    calNoOfFiles(tempDirPath);
            }

        }
        return noOfFiles;
    }

No comments:

Post a Comment

LinkWithin

Related Posts Plugin for WordPress, Blogger...