// Missing Statement
For(int i=0;i< dirs.length; i++)
System.out.println("Root[*+j+") : " + dirs[i]);
Answers
Answer:
Use listRoots() of File class to find all root directories.
Explanation:
Given: Piece of java code
Find: Missing of statement
Step 1:
Method 1:
import java.io.*;
public class GeeksforGeeks {
public static void main(String[] args)
{
File[] rDirs = File.listRoots();
for (int i = 0; i < rDirs.length; i++)
System.out.println(rDirs[i].toString());
}
}
Method 2:
To solve your issue with the TestX folders, First iterate through the list of folders:
File[] dirs = new File(".").listFiles(new WildcardFileFilter("Test*.java");
for (int i=0; i<dirs.length; i++) {
File dir = dirs[i];
if (dir.isDirectory()) {
File[] files = dir.listFiles(new WildcardFileFilter("sample*.java"));
}
}
Answer:
Use listRoots() of File class to find all root directories.
Explanation:
import java.io.*;
public class anj {
public static void main(String[] args)
{
File[] rDirs = File.listRoots();
for (int i = 0; i < rDirs.length; i++)
System.out.println(rDirs[i].toString());
}
}
To solve your issue with the TestX folders, First iterate through the list of folders:
File[] dirs = new File(".").listFiles(new WildcardFileFilter("Test*.java");
for (int i=0; i<dirs.length; i++) {
File dir = dirs[i];
if (dir.isDirectory()) {
File[] files = dir.listFiles(new WildcardFileFilter("sample*.java"));
}
}