Hi everyone,
I have written a code for retrieving contents of a windows partition "D:\" using recursion in java. Can anybody help me that why this from is not running. There is a
NullPointerException
shown as I involve that comment statement in code.
import java.io.*;
class u
{
static public void getFolders(String drive)
{
try
{
File a=new File(drive);
File b[]=a.listFiles();
for(int i=1;i<b.length;i++)
{
if(b[i].isDirectory()==true)
{
String str=b[i].getName().toString();
System.out.println(str);
}
}
}
catch(Exception er)
{
System.out.println(er);
}
}
public static void main(String args[])
{
u.getFolders("d:");
}
}
Thanks,
Akky