package display;
import java.io.File;
class display
{
int file=0, directory=0;
void list(String path)
{
File root = new File(path);
File[] f1 = root.listFiles();
for (File S : f1) //error
{
if(S.isDirectory())
{
list(S.getAbsolutePath());//error
directory++;
}
else if(S.isFile())
{
file++;
}
}
}
}
package display;
public class displaymain
{
public static void main(String[] args)
{
display d = new display();
d.list("d:\\");// error
System.out.println("No. of directories = "+d.directory);
System.out.println("No. of files = "+d.file);
}
}
Aditya_4 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.