Goodz13
June 21st, 2003, 05:24 PM
Q: How to search for files in a directory and subdirectories?
A: The following small program when executed like this:
java FileList *
should print a list of files in the current directory
// sample from Absolute Java FAQ (http://www.javafaq.nu/java/500/index.shtml?hop=jspecialis.javafaq)
public class FileList
{
public static void main(String args[])
{
for (int i = 0;i < args.length; i++)
{
System.out.println("File " + i + ":" + args[i]);
}
if (args.length<=0)
{
System.out.println("No files!");
}
}
}
<br>
A: The following small program when executed like this:
java FileList *
should print a list of files in the current directory
// sample from Absolute Java FAQ (http://www.javafaq.nu/java/500/index.shtml?hop=jspecialis.javafaq)
public class FileList
{
public static void main(String args[])
{
for (int i = 0;i < args.length; i++)
{
System.out.println("File " + i + ":" + args[i]);
}
if (args.length<=0)
{
System.out.println("No files!");
}
}
}
<br>